High-performance sphere primitive for collision detection and bounding volume applications.
The Sphere class represents a perfect mathematical sphere in 3D space, defined by a center point and radius. It provides optimized intersection tests with various geometric primitives and serves as an efficient bounding volume for complex objects.
Key features:
Performance characteristics:
Common applications:
Implementation notes:
#include <sphere.hpp>
Public Member Functions | |
constexpr | Sphere (const Vector3D ¢er, const Fxp &radius) |
Creates sphere from center and radius. | |
bool | Contains (const Vector3D &point) const |
Tests if a point is inside the sphere. | |
constexpr AABB | GetBoundingBox () const |
Calculates bounding box containing sphere. | |
constexpr Vector3D | GetPosition () const |
Gets shape center position. | |
constexpr Fxp | GetRadius () const |
Gets sphere radius. | |
template<Precision P = Precision::Default> | |
bool | Intersects (const AABB &box) const |
Tests intersection with AABB. | |
bool | Intersects (const Plane &plane) const override |
Tests intersection with plane. | |
bool | Intersects (const Sphere &other) const |
Tests intersection with another sphere. | |
constexpr void | SetPosition (const Vector3D &pos) |
Sets shape center position. | |
Protected Attributes | |
Vector3D | position |