Sphere.pkg 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. $#include "Sphere.h"
  2. /// %Sphere in three-dimensional space.
  3. class Sphere
  4. {
  5. public:
  6. /// Construct undefined.
  7. Sphere();
  8. /// Copy-construct from another sphere.
  9. Sphere(const Sphere& sphere);
  10. /// Construct from center and radius.
  11. Sphere(const Vector3& center, float radius);
  12. /// Construct from an array of vertices.
  13. Sphere(const Vector3* vertices, unsigned count);
  14. /// Construct from a bounding box.
  15. Sphere(const BoundingBox& box);
  16. /// Construct from a frustum.
  17. Sphere(const Frustum& frustum);
  18. /// Construct from a polyhedron.
  19. Sphere(const Polyhedron& poly);
  20. /// Test for equality with another sphere.
  21. bool operator == (const Sphere& rhs) const;
  22. /// Define from another sphere.
  23. void Define(const Sphere& sphere);
  24. /// Define from center and radius.
  25. void Define(const Vector3& center, float radius);
  26. /// Define from an array of vertices.
  27. void Define(const Vector3* vertices, unsigned count);
  28. /// Define from a bounding box.
  29. void Define(const BoundingBox& box);
  30. /// Define from a frustum.
  31. void Define(const Frustum& frustum);
  32. /// Define from a polyhedron.
  33. void Define(const Polyhedron& poly);
  34. /// Merge a point.
  35. void Merge(const Vector3& point);
  36. /// Merge an array of vertices.
  37. void Merge(const Vector3* vertices, unsigned count);
  38. /// Merge a bounding box.
  39. void Merge(const BoundingBox& box);
  40. /// Merge a frustum.
  41. void Merge(const Frustum& frustum);
  42. /// Merge a polyhedron.
  43. void Merge(const Polyhedron& poly);
  44. /// Merge a sphere.
  45. void Merge(const Sphere& sphere);
  46. /// Clear to undefined state.
  47. void Clear();
  48. /// Test if a point is inside.
  49. Intersection IsInside(const Vector3& point) const;
  50. /// Test if another sphere is inside, outside or intersects.
  51. Intersection IsInside(const Sphere& sphere) const;
  52. /// Test if another sphere is (partially) inside or outside.
  53. Intersection IsInsideFast(const Sphere& sphere) const;
  54. /// Test if a bounding box is inside, outside or intersects.
  55. Intersection IsInside(const BoundingBox& box) const;
  56. /// Test if a bounding box is (partially) inside or outside.
  57. Intersection IsInsideFast(const BoundingBox& box) const;
  58. /// Return distance of a point to the surface, or 0 if inside.
  59. float Distance(const Vector3& point) const;
  60. /// Sphere center.
  61. Vector3 center_ @ center;
  62. /// Sphere radius.
  63. float radius_ @ radius;
  64. };