Sphere.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include "Common.h"
  3. #include "Vector.h"
  4. NS_BF_BEGIN
  5. class Vector3;
  6. class Matrix4;
  7. class Sphere
  8. {
  9. public:
  10. Vector3 mCenter;
  11. float mRadius;
  12. Sphere();
  13. Sphere(const Sphere& X);
  14. Sphere(const Vector3& O); // Point-Sphere
  15. Sphere(const Vector3& O, float R); // Center and radius (not squared)
  16. Sphere(const Vector3& O, const Vector3& A); // Sphere through two points
  17. Sphere(const Vector3& O, const Vector3& A, const Vector3& B); // Sphere through three points
  18. Sphere(const Vector3& O, const Vector3& A, const Vector3& B, const Vector3& C); // Sphere through four points
  19. Sphere& operator=(const Sphere& S);
  20. float GetDistance(const Vector3& P) const; // Distance from p to boundary of the Sphere
  21. float GetDistanceSquare(const Vector3& P) const; // Square distance from p to boundary of the Sphere
  22. static float GetDistance(const Sphere& S, const Vector3& P); // Distance from p to boundary of the Sphere
  23. static float GetDistance(const Vector3& P, const Sphere& S); // Distance from p to boundary of the Sphere
  24. static float GetDistanceSquare(const Sphere& S, const Vector3& P); // Square distance from p to boundary of the Sphere
  25. static float GetDistanceSquare(const Vector3& P, const Sphere& S); // Square distance from p to boundary of the Sphere
  26. static Sphere MiniBall(Vector3 P[], int p); // Smallest enclosing sphere
  27. static Sphere SmallBall(Vector3 P[], int p); // Enclosing sphere approximation
  28. private:
  29. static Sphere RecurseMini(Vector3* P[], int p, int b = 0);
  30. };
  31. NS_BF_END