Ocean
Ocean::BoundingSphere Class Reference

This class implements a bounding sphere. More...

Inheritance diagram for Ocean::BoundingSphere:

Public Member Functions

 BoundingSphere ()
 Creates an invalid bounding sphere. More...
 
 BoundingSphere (const Vector3 &center, const Scalar radius)
 Creates a new bounding sphere by a center point and a radius. More...
 
 BoundingSphere (const BoundingBox &boundingBox)
 Creates a new bounding sphere by a given bounding box. More...
 
bool intersections (const Line3 &ray, Vector3 &position0, Scalar &distance0, Vector3 &position1, Scalar &distance1) const
 Returns both intersection points between a given ray and this sphere. More...
 
bool intersections (const Line3 &ray, const HomogenousMatrix4 &transformation, const HomogenousMatrix4 &invertedTransformation, Vector3 &position0, Scalar &distance0, Vector3 &position1, Scalar &distance1) const
 Returns both intersection points between a given ray and this sphere. More...
 
bool intersections (const Line3 &ray, Vector3 &position0, Scalar &distance0, Vector3 &normal0, Vector3 &position1, Scalar &distance1, Vector3 &normal1) const
 Returns both intersection points between a given ray and this sphere. More...
 
bool intersections (const Line3 &ray, const HomogenousMatrix4 &transformation, const HomogenousMatrix4 &invertedTransformation, Vector3 &position0, Scalar &distance0, Vector3 &normal0, Vector3 &position1, Scalar &distance1, Vector3 &normal1) const
 Returns both intersection points between a given ray and this sphere. More...
 
bool positiveFrontIntersection (const Line3 &ray, Vector3 &position, Scalar &distance) const
 Returns the front intersection point between a given ray and this sphere whenever the distance is positive. More...
 
bool positiveFrontIntersection (const Line3 &ray, Vector3 &position, Scalar &distance, Vector3 &normal) const
 Returns the front intersection point between a given ray and this sphere whenever the distance is positive. More...
 
bool positiveFrontIntersection (const Line3 &ray, const HomogenousMatrix4 &transformation, const HomogenousMatrix4 &invertedTransformation, Vector3 &position, Scalar &distance) const
 Returns the front intersection point between a given ray and this sphere whenever the distance is positive. More...
 
bool positiveFrontIntersection (const Line3 &ray, const HomogenousMatrix4 &transformation, const HomogenousMatrix4 &invertedTransformation, Vector3 &position, Scalar &distance, Vector3 &normal) const
 Returns the front intersection point between a given ray and this sphere whenever the distance is positive. More...
 
bool positiveBackIntersection (const Line3 &ray, Vector3 &position, Scalar &distance) const
 Returns the back intersection point between a given ray and this sphere whenever the distance is positive. More...
 
bool positiveBackIntersection (const Line3 &ray, Vector3 &position, Scalar &distance, Vector3 &normal) const
 Returns the back intersection point between a given ray and this sphere whenever the distance is positive. More...
 
bool positiveBackIntersection (const Line3 &ray, const HomogenousMatrix4 &transformation, const HomogenousMatrix4 &invertedTransformation, Vector3 &position, Scalar &distance) const
 Returns the back intersection point between a given ray and this sphere whenever the distance is positive. More...
 
bool positiveBackIntersection (const Line3 &ray, const HomogenousMatrix4 &transformation, const HomogenousMatrix4 &invertedTransformation, Vector3 &position, Scalar &distance, Vector3 &normal) const
 Returns the back intersection point between a given ray and this sphere whenever the distance is positive. More...
 
- Public Member Functions inherited from Ocean::SphereT3< Scalar >
 SphereT3 ()=default
 Creates an invalid sphere. More...
 
 SphereT3 (const VectorT3< Scalar > &center, const Scalar radius)
 Creates a new sphere by a center point and a radius. More...
 
 SphereT3 (const BoxT3< Scalar > &boundingBox)
 Creates a new sphere entirely containing a given 3D box. More...
 
const VectorT3< Scalar > & center () const
 Returns the center of the sphere. More...
 
const Scalarradius () const
 Returns the radius of the sphere. More...
 
bool isInside (const VectorT3< Scalar > &point) const
 Returns whether a given point is inside this sphere. More...
 
bool isInsideEps (const VectorT3< Scalar > &point, const Scalar eps=NumericT< Scalar >::eps()) const
 Returns whether a given point is inside this sphere including a thin epsilon boundary. More...
 
bool hasIntersection (const LineT3< Scalar > &ray) const
 Returns whether a given ray has an intersection with this sphere. More...
 
bool hasIntersection (const LineT3< Scalar > &ray, const HomogenousMatrixT4< Scalar > &sphere_T_ray) const
 Returns whether a given ray has an intersection with this sphere. More...
 
bool hasIntersection (const SphereT3< Scalar > &sphere) const
 Returns whether two spheres have an intersection. More...
 
bool isValid () const
 Returns whether this radius of this sphere is not negative and thus the sphere is valid. More...
 
SphereT3< Scalaroperator* (const Scalar factor) const
 Returns a new sphere with an enlarged radius (the center of the sphere stays constant). More...
 
SphereT3< Scalar > & operator*= (const Scalar factor)
 Multiplies the radius of this sphere with a given factor. More...
 

Private Attributes

Scalar inverseRadius_
 Inverse of the sphere radius. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Ocean::SphereT3< Scalar >
static VectorT3< ScalarcoordinateToVector (const Scalar latitude, const Scalar longitude)
 Converts a 2D location coordinate on the surface of a unit sphere to a vector with unit length. More...
 
static void vectorToCoordinate (const VectorT3< Scalar > &coordinateVector, Scalar &latitude, Scalar &longitude)
 Converts a vector pointing to the surface of a unit sphere to a 2D location coordinate. More...
 
static Scalar shortestDistance (const Scalar latitudeA, const Scalar longitudeA, const Scalar latitudeB, const Scalar longitudeB)
 Calculates the shortest distance between two 2D location coordinates on the surface of a unit sphere. More...
 
- Protected Attributes inherited from Ocean::SphereT3< Scalar >
VectorT3< Scalarcenter_
 Sphere center. More...
 
Scalar radius_
 Sphere radius. More...
 

Detailed Description

This class implements a bounding sphere.

Constructor & Destructor Documentation

◆ BoundingSphere() [1/3]

Ocean::BoundingSphere::BoundingSphere ( )
inline

Creates an invalid bounding sphere.

◆ BoundingSphere() [2/3]

Ocean::BoundingSphere::BoundingSphere ( const Vector3 center,
const Scalar  radius 
)
inline

Creates a new bounding sphere by a center point and a radius.

Parameters
centerCenter of the bounding sphere
radiusRadius of the bounding sphere

◆ BoundingSphere() [3/3]

Ocean::BoundingSphere::BoundingSphere ( const BoundingBox boundingBox)
inlineexplicit

Creates a new bounding sphere by a given bounding box.

Parameters
boundingBoxBounding box to be converted

Member Function Documentation

◆ intersections() [1/4]

bool Ocean::BoundingSphere::intersections ( const Line3 ray,
const HomogenousMatrix4 transformation,
const HomogenousMatrix4 invertedTransformation,
Vector3 position0,
Scalar distance0,
Vector3 normal0,
Vector3 position1,
Scalar distance1,
Vector3 normal1 
) const
inline

Returns both intersection points between a given ray and this sphere.

The intersection points are determined without consideration of the ray direction
.

Parameters
rayRay to determine the nearest intersection point for
transformationTransformation of the given world transformation (for the sphere)
invertedTransformationInverted transformation of the given world transformation (for the sphere)
position0Resulting nearest intersection position
distance0Resulting nearest intersection distance, regarding to the length of the ray direction
normal0Resulting nearest intersection normal
position1Resulting farthest intersection position
distance1Resulting farthest intersection distance, regarding to the length of the ray direction
normal1Resulting farthest intersection normal
Returns
True, if so

◆ intersections() [2/4]

bool Ocean::BoundingSphere::intersections ( const Line3 ray,
const HomogenousMatrix4 transformation,
const HomogenousMatrix4 invertedTransformation,
Vector3 position0,
Scalar distance0,
Vector3 position1,
Scalar distance1 
) const
inline

Returns both intersection points between a given ray and this sphere.

The intersection points are determined without consideration of the ray direction
.

Parameters
rayRay to determine the nearest intersection point for
transformationTransformation of the given world transformation (for the sphere)
invertedTransformationInverted transformation of the given world transformation (for the sphere)
position0Resulting nearest intersection position
distance0Resulting nearest intersection distance, regarding to the length of the ray direction
position1Resulting farthest intersection position
distance1Resulting farthest intersection distance, regarding to the length of the ray direction
Returns
True, if so

◆ intersections() [3/4]

bool Ocean::BoundingSphere::intersections ( const Line3 ray,
Vector3 position0,
Scalar distance0,
Vector3 normal0,
Vector3 position1,
Scalar distance1,
Vector3 normal1 
) const
inline

Returns both intersection points between a given ray and this sphere.

The intersection points are determined without consideration of the ray direction
.

Parameters
rayRay to determine the nearest intersection point for
position0Resulting nearest intersection position
distance0Resulting nearest intersection distance, regarding to the length of the ray direction
normal0Resulting nearest intersection normal
position1Resulting farthest intersection position
distance1Resulting farthest intersection distance, regarding to the length of the ray direction
normal1Resulting farthest intersection normal
Returns
True, if so

◆ intersections() [4/4]

bool Ocean::BoundingSphere::intersections ( const Line3 ray,
Vector3 position0,
Scalar distance0,
Vector3 position1,
Scalar distance1 
) const

Returns both intersection points between a given ray and this sphere.

The intersection points are determined without consideration of the ray direction
.

Parameters
rayRay to determine the nearest intersection point for
position0Resulting nearest intersection position
distance0Resulting nearest intersection distance, regarding to the length of the ray direction
position1Resulting farthest intersection position
distance1Resulting farthest intersection distance, regarding to the length of the ray direction
Returns
True, if so

◆ positiveBackIntersection() [1/4]

bool Ocean::BoundingSphere::positiveBackIntersection ( const Line3 ray,
const HomogenousMatrix4 transformation,
const HomogenousMatrix4 invertedTransformation,
Vector3 position,
Scalar distance 
) const
inline

Returns the back intersection point between a given ray and this sphere whenever the distance is positive.

The dot product between the ray direction and the intersection normal will be positive.

Parameters
rayRay to determine the intersection point for
transformationTransformation of the given world transformation (for the sphere)
invertedTransformationInverted transformation of the given world transformation (for the sphere)
positionResulting intersection position
distanceResulting intersection distance
Returns
True, if so

◆ positiveBackIntersection() [2/4]

bool Ocean::BoundingSphere::positiveBackIntersection ( const Line3 ray,
const HomogenousMatrix4 transformation,
const HomogenousMatrix4 invertedTransformation,
Vector3 position,
Scalar distance,
Vector3 normal 
) const
inline

Returns the back intersection point between a given ray and this sphere whenever the distance is positive.

The dot product between the ray direction and the intersection normal will be positive.

Parameters
rayRay to determine the intersection point for
transformationTransformation of the given world transformation (for the sphere)
invertedTransformationInverted transformation of the given world transformation (for the sphere)
positionResulting intersection position
distanceResulting intersection distance
normalResulting intersection normal
Returns
True, if so

◆ positiveBackIntersection() [3/4]

bool Ocean::BoundingSphere::positiveBackIntersection ( const Line3 ray,
Vector3 position,
Scalar distance 
) const

Returns the back intersection point between a given ray and this sphere whenever the distance is positive.

The dot product between the ray direction and the intersection normal will be positive.

Parameters
rayRay to determine the intersection point for
positionResulting intersection position
distanceResulting intersection distance
Returns
True, if so

◆ positiveBackIntersection() [4/4]

bool Ocean::BoundingSphere::positiveBackIntersection ( const Line3 ray,
Vector3 position,
Scalar distance,
Vector3 normal 
) const
inline

Returns the back intersection point between a given ray and this sphere whenever the distance is positive.

The dot product between the ray direction and the intersection normal will be positive.

Parameters
rayRay to determine the intersection point for
positionResulting intersection position
distanceResulting intersection distance
normalResulting intersection normal
Returns
True, if so

◆ positiveFrontIntersection() [1/4]

bool Ocean::BoundingSphere::positiveFrontIntersection ( const Line3 ray,
const HomogenousMatrix4 transformation,
const HomogenousMatrix4 invertedTransformation,
Vector3 position,
Scalar distance 
) const
inline

Returns the front intersection point between a given ray and this sphere whenever the distance is positive.

The dot product between the ray direction and the intersection normal will be negative.

Parameters
rayRay to determine the intersection point for
transformationTransformation of the given world transformation (for the sphere)
invertedTransformationInverted transformation of the given world transformation (for the sphere)
positionResulting intersection position
distanceResulting intersection distance
Returns
True, if so

◆ positiveFrontIntersection() [2/4]

bool Ocean::BoundingSphere::positiveFrontIntersection ( const Line3 ray,
const HomogenousMatrix4 transformation,
const HomogenousMatrix4 invertedTransformation,
Vector3 position,
Scalar distance,
Vector3 normal 
) const
inline

Returns the front intersection point between a given ray and this sphere whenever the distance is positive.

The dot product between the ray direction and the intersection normal will be negative.

Parameters
rayRay to determine the intersection point for
transformationTransformation of the given world transformation (for the sphere)
invertedTransformationInverted transformation of the given world transformation (for the sphere)
positionResulting intersection position
distanceResulting intersection distance
normalResulting intersection normal
Returns
True, if so

◆ positiveFrontIntersection() [3/4]

bool Ocean::BoundingSphere::positiveFrontIntersection ( const Line3 ray,
Vector3 position,
Scalar distance 
) const

Returns the front intersection point between a given ray and this sphere whenever the distance is positive.

The dot product between the ray direction and the intersection normal will be negative.

Parameters
rayRay to determine the intersection point for
positionResulting intersection position
distanceResulting intersection distance
Returns
True, if so

◆ positiveFrontIntersection() [4/4]

bool Ocean::BoundingSphere::positiveFrontIntersection ( const Line3 ray,
Vector3 position,
Scalar distance,
Vector3 normal 
) const
inline

Returns the front intersection point between a given ray and this sphere whenever the distance is positive.

The dot product between the ray direction and the intersection normal will be negative.

Parameters
rayRay to determine the intersection point for
positionResulting intersection position
distanceResulting intersection distance
normalResulting intersection normal
Returns
True, if so

Field Documentation

◆ inverseRadius_

Scalar Ocean::BoundingSphere::inverseRadius_
private

Inverse of the sphere radius.


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