Ocean
Ocean::BoundingBox Class Reference

This class implements a 3D bounding box. More...

Inheritance diagram for Ocean::BoundingBox:

Public Member Functions

 BoundingBox ()
 Creates an invalid bounding box. More...
 
 BoundingBox (const Box3 &box)
 Creates an invalid bounding box. More...
 
 BoundingBox (const Vector3 &lower, const Vector3 &higher)
 Creates a new bounding box by two given corners. More...
 
 BoundingBox (const Vectors3 &points)
 Creates a new bounding box enclosing a given set of 3D points. More...
 
 BoundingBox (const Vector3 *points, const unsigned int number)
 Creates a new bounding box enclosing a given set of 3D points. More...
 
bool positiveFrontIntersection (const Line3 &ray, Vector3 &position, Scalar &distance) const
 Returns the front intersection point between a given ray and this box 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 box whenever the distance is positive. More...
 
bool positiveFrontIntersection (const Line3 &ray, Vector3 &position, Scalar &distance, Vector3 &normal, Vector2 &textureCoordinate) const
 Returns the front intersection point between a given ray and this box whenever the distance is positive. More...
 
bool positiveFrontIntersection (const Line3 &ray, const HomogenousMatrix4 &transformation, const HomogenousMatrix4 &invertedTransformation, Vector3 &position, Scalar &distance) const
 Returns whether a given ray has an intersection with this box. More...
 
bool positiveFrontIntersection (const Line3 &ray, const HomogenousMatrix4 &transformation, const HomogenousMatrix4 &invertedTransformation, Vector3 &position, Scalar &distance, Vector3 &normal) const
 Returns whether a given ray has an intersection with this box. More...
 
bool positiveFrontIntersection (const Line3 &ray, const HomogenousMatrix4 &transformation, const HomogenousMatrix4 &invertedTransformation, Vector3 &position, Scalar &distance, Vector3 &normal, Vector2 &textureCoordinate) const
 Returns the front intersection point between a given ray and this box 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 box 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 box whenever the distance is positive. More...
 
bool positiveBackIntersection (const Line3 &ray, Vector3 &position, Scalar &distance, Vector3 &normal, Vector2 &textureCoordinate) const
 Returns the back intersection point between a given ray and this box 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 box 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 box whenever the distance is positive. More...
 
bool positiveBackIntersection (const Line3 &ray, const HomogenousMatrix4 &transformation, const HomogenousMatrix4 &invertedTransformation, Vector3 &position, Scalar &distance, Vector3 &normal, Vector2 &textureCoordinate) const
 Returns the back intersection point between a given ray and this box whenever the distance is positive. More...
 
- Public Member Functions inherited from Ocean::BoxT3< Scalar >
 BoxT3 ()=default
 Creates an invalid bounding box. More...
 
 BoxT3 (const VectorT3< Scalar > &lower, const VectorT3< Scalar > &higher)
 Creates a new bounding box by two given corners. More...
 
 BoxT3 (const VectorsT3< Scalar > &points)
 Creates a new bounding box enclosing a given set of 3D points. More...
 
 BoxT3 (const VectorT3< Scalar > *points, const size_t number)
 Creates a new bounding box enclosing a given set of 3D points. More...
 
 BoxT3 (const VectorT3< Scalar > &center, const Scalar xSize, const Scalar ySize, const Scalar zSize)
 Creates a new bounding box with defined dimensions centered at a given 3D location. More...
 
VectorT3< Scalarcenter () const
 Returns the center of the box. More...
 
Scalar sqrDiagonal () const
 Returns the square diagonal of this box. More...
 
Scalar diagonal () const
 Returns the diagonal of this box. More...
 
Scalar xDimension () const
 Returns the dimension in x axis, which could e.g. More...
 
Scalar yDimension () const
 Returns the dimension in y axis, which could e.g. More...
 
Scalar zDimension () const
 Returns the dimension in z axis, which could e.g. More...
 
VectorT3< Scalardimension () const
 Returns the dimension of this box for all three axis. More...
 
bool isPoint (VectorT3< Scalar > *point=nullptr) const
 Returns whether this box defines one single point only. More...
 
bool isPlanar (PlaneT3< Scalar > &plane) const
 Returns whether this box is planar aligned to one axis. More...
 
const VectorT3< Scalar > & lower () const
 Returns the lower corner of the box. More...
 
const VectorT3< Scalar > & higher () const
 Returns the higher corner of the box. More...
 
bool isInside (const VectorT3< Scalar > &point, const Scalar eps=Scalar(0)) const
 Returns whether a given point is inside this bounding box. More...
 
bool isOnSurface (const VectorT3< Scalar > &point, const Scalar epsilon=NumericT< Scalar >::eps()) const
 Returns whether a given point lies on the surface of this box. More...
 
bool hasIntersection (const LineT3< Scalar > &ray) const
 Returns whether a given ray has an intersection with this box. More...
 
bool hasIntersection (const LineT3< Scalar > &ray, const Scalar epsPerDistance) const
 Returns whether a given ray has an intersection with this box while applying a distance-dependent epsilon threshold. More...
 
bool hasIntersection (const LineT3< Scalar > &ray, const HomogenousMatrixT4< Scalar > &box_T_ray) const
 Returns whether a given ray has an intersection with this box. More...
 
unsigned int corners (VectorT3< Scalar > *corners) const
 Returns the corner positions of this box. More...
 
BoxT3< Scalarexpanded (const VectorT3< Scalar > &offsets) const
 Returns an expanded box of this box. More...
 
BoxT3< Scalar > & expand (const VectorT3< Scalar > &offsets)
 Expands this box. More...
 
void clear ()
 Clears and resets the bounding box to an invalid box. More...
 
bool isEqual (const BoxT3< Scalar > &box, const Scalar epsilon=NumericT< Scalar >::eps()) const
 Returns whether two box objects are equal up to an epsilon. More...
 
bool isValid () const
 Returns whether the bounding box is valid. More...
 
BoxT3< Scalaroperator* (const Scalar factor) const
 Returns an enlarged bounding box of this one. More...
 
BoxT3< Scalaroperator* (const HomogenousMatrixT4< Scalar > &world_T_box) const
 Returns the (axis-aligned) world bounding box for a given transformation between the box and world. More...
 
BoxT3< Scalar > & operator*= (const Scalar factor)
 Enlarges the bounding box by a given factor in each dimension. More...
 
BoxT3< Scalar > & operator*= (const HomogenousMatrixT4< Scalar > &world_T_box)
 Transforms this bounding box with a given transformation so that the this bounding box is defined in world afterwards. More...
 
BoxT3< Scalar > & operator+= (const VectorT3< Scalar > &point)
 Adds a new point to this bounding box and updates it's dimension. More...
 
BoxT3< Scalar > & operator+= (const BoxT3< Scalar > &right)
 Joins to bounding boxes. More...
 
BoxT3< Scalaroperator+ (const BoxT3< Scalar > &right) const
 Returns the union of two bounding boxes. More...
 
bool operator== (const BoxT3< Scalar > &right) const
 Returns whether two boxes are identical. More...
 
bool operator!= (const BoxT3< Scalar > &right) const
 Returns whether two boxes are not identical. More...
 
 operator bool () const
 Returns whether this box is not a default box. More...
 

Additional Inherited Members

- Protected Attributes inherited from Ocean::BoxT3< Scalar >
VectorT3< Scalarlower_
 Lower corner of the bounding box. More...
 
VectorT3< Scalarhigher_
 Higher corner of the bounding box. More...
 

Detailed Description

This class implements a 3D bounding box.

Constructor & Destructor Documentation

◆ BoundingBox() [1/5]

Ocean::BoundingBox::BoundingBox ( )
inline

Creates an invalid bounding box.

◆ BoundingBox() [2/5]

Ocean::BoundingBox::BoundingBox ( const Box3 box)
inline

Creates an invalid bounding box.

◆ BoundingBox() [3/5]

Ocean::BoundingBox::BoundingBox ( const Vector3 lower,
const Vector3 higher 
)
inline

Creates a new bounding box by two given corners.

Parameters
lowerLower corner
higherHigher corner

◆ BoundingBox() [4/5]

Ocean::BoundingBox::BoundingBox ( const Vectors3 points)
inlineexplicit

Creates a new bounding box enclosing a given set of 3D points.

Parameters
pointsPoints to be enclosed by the bounding box

◆ BoundingBox() [5/5]

Ocean::BoundingBox::BoundingBox ( const Vector3 points,
const unsigned int  number 
)
inline

Creates a new bounding box enclosing a given set of 3D points.

Parameters
pointsPoints to be enclosed by the bounding box
numberNumber of points

Member Function Documentation

◆ positiveBackIntersection() [1/6]

bool Ocean::BoundingBox::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 box 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 this box)
positionResulting intersection position
distanceResulting intersection distance
Returns
True, if so

◆ positiveBackIntersection() [2/6]

bool Ocean::BoundingBox::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 box 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 this box)
positionResulting intersection position
distanceResulting intersection distance
normalResulting intersection normal
Returns
True, if so

◆ positiveBackIntersection() [3/6]

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

Returns the back intersection point between a given ray and this box 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 this box)
positionResulting intersection position
distanceResulting intersection distance
normalResulting intersection normal
textureCoordinateResulting texture coordinate
Returns
True, if so

◆ positiveBackIntersection() [4/6]

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

Returns the back intersection point between a given ray and this box 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() [5/6]

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

Returns the back intersection point between a given ray and this box 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

◆ positiveBackIntersection() [6/6]

bool Ocean::BoundingBox::positiveBackIntersection ( const Line3 ray,
Vector3 position,
Scalar distance,
Vector3 normal,
Vector2 textureCoordinate 
) const

Returns the back intersection point between a given ray and this box 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
textureCoordinateResulting texture coordinate
Returns
True, if so

◆ positiveFrontIntersection() [1/6]

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

Returns whether a given ray has an intersection with this box.

Parameters
rayRay to be tested
transformationTransformation of the given world transformation (for the box)
invertedTransformationInverted transformation of the given world transformation (for this box)
positionResulting nearest intersection position
distanceResulting intersection distance
Returns
True, if so

◆ positiveFrontIntersection() [2/6]

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

Returns whether a given ray has an intersection with this box.

Parameters
rayRay to be tested
transformationTransformation of the given world transformation (for the box)
invertedTransformationInverted transformation of the given world transformation (for this box)
positionResulting nearest intersection position
distanceResulting intersection distance
normalResulting intersection normal
Returns
True, if so

◆ positiveFrontIntersection() [3/6]

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

Returns the front intersection point between a given ray and this box 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 box)
invertedTransformationInverted transformation of the given world transformation (for this box)
positionResulting intersection position
distanceResulting intersection distance
normalResulting intersection normal
textureCoordinateResulting texture coordinate
Returns
True, if so

◆ positiveFrontIntersection() [4/6]

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

Returns the front intersection point between a given ray and this box 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() [5/6]

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

Returns the front intersection point between a given ray and this box 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

◆ positiveFrontIntersection() [6/6]

bool Ocean::BoundingBox::positiveFrontIntersection ( const Line3 ray,
Vector3 position,
Scalar distance,
Vector3 normal,
Vector2 textureCoordinate 
) const

Returns the front intersection point between a given ray and this box 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
textureCoordinateResulting texture coordinate
Returns
True, if so

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