Ocular Engine
Ocular::Math::BoundsSphere Class Reference
Inheritance diagram for Ocular::Math::BoundsSphere:
Ocular::Math::Bounds

Public Member Functions

 BoundsSphere (std::list< Point3f > const &points, Math::Matrix4x4 const &matrix=Math::Matrix4x4())
 
 BoundsSphere (std::vector< Graphics::Vertex > const &vertices, Math::Matrix4x4 const &matrix=Math::Matrix4x4())
 
 BoundsSphere (Vector3f const &center, float radius)
 
void construct (std::list< Vector3f > const &points, Math::Matrix4x4 const &matrix=Math::Matrix4x4())
 
void construct (std::vector< Graphics::Vertex > const &vertices, Math::Matrix4x4 const &matrix=Math::Matrix4x4())
 
void setCenter (Vector3f const &center)
 
void setRadius (float radius)
 
Vector3f const & getCenter () const
 
float getRadius () const
 
void expand (float const amount)
 
void expandToContain (Vector3f const &point)
 
void expandToContain (BoundsSphere const &other)
 
bool intersects (Ray const &ray) const
 
bool intersects (Ray const &ray, Vector3f &point, float &distance) const
 
bool intersects (BoundsSphere const &bounds) const
 
bool intersects (BoundsAABB const &bounds) const
 
bool intersects (BoundsOBB const &bounds) const
 
bool intersects (Plane const &plane, IntersectionType *result=nullptr) const
 
bool contains (Vector3f const &point, IntersectionType *result=nullptr) const
 
bool contains (BoundsSphere const &sphere, IntersectionType *result=nullptr) const
 
- Public Member Functions inherited from Ocular::Math::Bounds
BoundsType getType () const
 
bool isVisible () const
 
void setVisible (bool visible)
 

Additional Inherited Members

- Protected Member Functions inherited from Ocular::Math::Bounds
 Bounds (BoundsType const type)
 
- Protected Attributes inherited from Ocular::Math::Bounds
bool m_Visible
 
BoundsType m_Type
 

Member Function Documentation

void Ocular::Math::BoundsSphere::construct ( std::list< Vector3f > const &  points,
Math::Matrix4x4 const &  matrix = Math::Matrix4x4() 
)

Constructs the bounds from a collection of spatial points.

Parameters
[in]points
bool Ocular::Math::BoundsSphere::contains ( Vector3f const &  point,
IntersectionType *  result = nullptr 
) const

Calculates if the bounds contains the specified point.

Parameters
[in]point
[out]resultThe exact result of the containment test (intersection, outside, inside).
Returns
TRUE if point is inside or intersects.
bool Ocular::Math::BoundsSphere::contains ( BoundsSphere const &  sphere,
IntersectionType *  result = nullptr 
) const

Calculates if any portion of the specified bounding sphere is contained within the spere.

Parameters
[in]sphere
[out]resultThe exact result of the containment test (intersection, outside, inside).
Returns
TRUE if bounds is inside or intersects.
void Ocular::Math::BoundsSphere::expand ( float const  amount)

Expands the radius of the bounding sphere by the specified amount.

Parameters
[in]amount
void Ocular::Math::BoundsSphere::expandToContain ( Vector3f const &  point)

Expands the bounding sphere so that it contains the specified point. If the point is already in the sphere then no action is taken.

Parameters
[in]point
void Ocular::Math::BoundsSphere::expandToContain ( BoundsSphere const &  other)

Expands the bounding sphere so that it contains the second bounding sphere. If the second sphere is already contained then no action is taken.

Parameters
[in]other
Vector3f const & Ocular::Math::BoundsSphere::getCenter ( ) const

Returns the center of the bounding sphere.

float Ocular::Math::BoundsSphere::getRadius ( ) const

Returns the radius of the bounding sphere.

bool Ocular::Math::BoundsSphere::intersects ( Ray const &  ray) const

Performs an intersection test on a ray and bounding sphere.

Parameters
[in]ray
Returns
TRUE if the ray and bounding sphere intersect.
bool Ocular::Math::BoundsSphere::intersects ( Ray const &  ray,
Vector3f point,
float &  distance 
) const

Performs an intersection test on a ray and bounding sphere.

This version of the method also returns the point at which the two intersect. If speed is of the uptmost concern and/or the exact point of intersection is not required, then the other version may be used instead.

Parameters
[in]ray
[out]pointThe point that the ray and bounding sphere intersects.
[out]distanceThe distance from the ray origin to the point of intersection
Returns
TRUE if the ray and bounding sphere intersect.
bool Ocular::Math::BoundsSphere::intersects ( BoundsSphere const &  bounds) const

Performs an intersection test on two bounding spheres.

Parameters
[in]bounds
Returns
TRUE if the two bounding spheres intersect.
bool Ocular::Math::BoundsSphere::intersects ( BoundsAABB const &  bounds) const

Performs an intersection test on a bounding sphere and AABB.

Parameters
[in]bounds
Returns
TRUE if the bounding sphere and AABB intersect.
bool Ocular::Math::BoundsSphere::intersects ( BoundsOBB const &  bounds) const

Performs an intersection test on a bounding sphere and OBB.

Parameters
[in]bounds
Returns
TRUE if the bounding sphere and OBB intersect.
bool Ocular::Math::BoundsSphere::intersects ( Plane const &  plane,
IntersectionType *  result = nullptr 
) const

Performs an intersection test on a plane and sphere.

If the result is Inside, then the sphere is located entirely within the plane's positive half space.
If the result is Outside, then the sphere is located entirely outside the plane's positive half space.

The positive half space of the plane is the direction that the plane is facing, as described by it's normal.

As an example, say we have the plane defined as:

 Point: (0.0, 0.0, 0.0)
Normal: (0.0, 1.0, 0.0)

The plane is 'facing up' along the world origin.

If the intersection test returns Outside, then the AABB is entirely in the +y world space.
If the intersection test returns Inside, then the AABB is entirely in the -y world space.

Parameters
[in]plane
[out]resultDetailed intersection result.
Returns
TRUE if the plane sphere AABB intersects, otherwise FALSE.
void Ocular::Math::BoundsSphere::setCenter ( Vector3f const &  center)

Sets the center of the bounding sphere.

Parameters
[in]center
void Ocular::Math::BoundsSphere::setRadius ( float  radius)

Sets the radius of the bounding sphere.

Parameters
[in]radius

The documentation for this class was generated from the following files: