Sphere
Useful for fast intersection tests, frustum culling, and spatial bounds.
Properties
radius float
float radius { -1.0f }
Radius of the sphere. A negative value indicates an empty sphere.
Functions
ApplyTransform() auto
auto vglx::Sphere::ApplyTransform(const Matrix4 &transform)
Parameter | Description |
---|---|
transform | 4x4 matrix to apply to the sphere. |
Transforms the sphere by the given matrix. The center is transformed directly, and the radius is scaled by the maximum scale component of the matrix.
ExpandWithPoint() auto
auto vglx::Sphere::ExpandWithPoint(const Vector3 &p)
Parameter | Description |
---|---|
p | Point to include in the sphere. |
Expands the sphere to include a given point. If the sphere is empty, it is initialized with the point. Otherwise, the sphere expands just enough to include the point.
IsEmpty() auto
auto vglx::Sphere::IsEmpty() const
Checks if the sphere is empty. An empty sphere is defined by a negative radius.
Reset() auto
auto vglx::Sphere::Reset()
Resets the sphere to an empty state. Sets the center to (0, 0, 0) and the radius to -1.
Sphere() constexpr
vglx::Sphere::Sphere(const Vector3 center, float radius)
Parameter | Description |
---|---|
center | Center position. |
radius | Radius. |
Constructs a Sphere from a center and a radius.
Translate() auto
auto vglx::Sphere::Translate(const Vector3 &translation)
Parameter | Description |
---|---|
translation | Vector to translate by. |
Translates the sphere by a constant vector.
Union() auto
auto vglx::Sphere::Union(const Sphere &other)
Parameter | Description |
---|---|
other | The sphere to merge into this one. |
Expands this sphere to fully contain another sphere.