Ocean
Ocean::BoxT3< T > Class Template Reference

This class implements an axis aligned 3D bounding box. More...

Inheritance diagram for Ocean::BoxT3< T >:

Public Member Functions

 BoxT3 ()=default
 Creates an invalid bounding box. More...
 
 BoxT3 (const VectorT3< T > &lower, const VectorT3< T > &higher)
 Creates a new bounding box by two given corners. More...
 
 BoxT3 (const VectorsT3< T > &points)
 Creates a new bounding box enclosing a given set of 3D points. More...
 
 BoxT3 (const VectorT3< T > *points, const size_t number)
 Creates a new bounding box enclosing a given set of 3D points. More...
 
 BoxT3 (const VectorT3< T > &center, const T xSize, const T ySize, const T zSize)
 Creates a new bounding box with defined dimensions centered at a given 3D location. More...
 
VectorT3< T > center () const
 Returns the center of the box. More...
 
sqrDiagonal () const
 Returns the square diagonal of this box. More...
 
diagonal () const
 Returns the diagonal of this box. More...
 
xDimension () const
 Returns the dimension in x axis, which could e.g. More...
 
yDimension () const
 Returns the dimension in y axis, which could e.g. More...
 
zDimension () const
 Returns the dimension in z axis, which could e.g. More...
 
VectorT3< T > dimension () const
 Returns the dimension of this box for all three axis. More...
 
bool isPoint (VectorT3< T > *point=nullptr) const
 Returns whether this box defines one single point only. More...
 
bool isPlanar (PlaneT3< T > &plane) const
 Returns whether this box is planar aligned to one axis. More...
 
const VectorT3< T > & lower () const
 Returns the lower corner of the box. More...
 
const VectorT3< T > & higher () const
 Returns the higher corner of the box. More...
 
bool isInside (const VectorT3< T > &point, const T eps=T(0)) const
 Returns whether a given point is inside this bounding box. More...
 
bool isOnSurface (const VectorT3< T > &point, const T epsilon=NumericT< T >::eps()) const
 Returns whether a given point lies on the surface of this box. More...
 
bool hasIntersection (const LineT3< T > &ray) const
 Returns whether a given ray has an intersection with this box. More...
 
bool hasIntersection (const LineT3< T > &ray, const T 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< T > &ray, const HomogenousMatrixT4< T > &box_T_ray) const
 Returns whether a given ray has an intersection with this box. More...
 
unsigned int corners (VectorT3< T > *corners) const
 Returns the corner positions of this box. More...
 
BoxT3< T > expanded (const VectorT3< T > &offsets) const
 Returns an expanded box of this box. More...
 
BoxT3< T > & expand (const VectorT3< T > &offsets)
 Expands this box. More...
 
void clear ()
 Clears and resets the bounding box to an invalid box. More...
 
bool isEqual (const BoxT3< T > &box, const T epsilon=NumericT< T >::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< T > operator* (const T factor) const
 Returns an enlarged bounding box of this one. More...
 
BoxT3< T > & operator*= (const T factor)
 Enlarges the bounding box by a given factor in each dimension. More...
 
BoxT3< T > & operator+= (const VectorT3< T > &point)
 Adds a new point to this bounding box and updates it's dimension. More...
 
BoxT3< T > operator+ (const BoxT3< T > &right) const
 Returns the union of two bounding boxes. More...
 
BoxT3< T > & operator+= (const BoxT3< T > &right)
 Joins to bounding boxes. More...
 
BoxT3< T > operator* (const HomogenousMatrixT4< T > &world_T_box) const
 Returns the (axis-aligned) world bounding box for a given transformation between the box and world. More...
 
BoxT3< T > & operator*= (const HomogenousMatrixT4< T > &world_T_box)
 Transforms this bounding box with a given transformation so that the this bounding box is defined in world afterwards. More...
 
bool operator== (const BoxT3< T > &right) const
 Returns whether two boxes are identical. More...
 
bool operator!= (const BoxT3< T > &right) const
 Returns whether two boxes are not identical. More...
 
 operator bool () const
 Returns whether this box is not a default box. More...
 

Protected Attributes

VectorT3< T > lower_ = VectorT3<T>(NumericT<T>::maxValue(), NumericT<T>::maxValue(), NumericT<T>::maxValue())
 Lower corner of the bounding box. More...
 
VectorT3< T > higher_ = VectorT3<T>(NumericT<T>::minValue(), NumericT<T>::minValue(), NumericT<T>::minValue())
 Higher corner of the bounding box. More...
 

Detailed Description

template<typename T>
class Ocean::BoxT3< T >

This class implements an axis aligned 3D bounding box.

Template Parameters
TThe data type of the scalar to be used, either 'float' or 'double'
See also
Box2, BoxF3, BoxD3, BoxT2.

Constructor & Destructor Documentation

◆ BoxT3() [1/5]

template<typename T >
Ocean::BoxT3< T >::BoxT3 ( )
default

Creates an invalid bounding box.

◆ BoxT3() [2/5]

template<typename T >
Ocean::BoxT3< T >::BoxT3 ( const VectorT3< T > &  lower,
const VectorT3< T > &  higher 
)

Creates a new bounding box by two given corners.

Parameters
lowerThe lower corner
higherThe higher corner

◆ BoxT3() [3/5]

template<typename T >
Ocean::BoxT3< T >::BoxT3 ( const VectorsT3< T > &  points)
explicit

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

Parameters
pointsThe points to be enclosed by the bounding box

◆ BoxT3() [4/5]

template<typename T >
Ocean::BoxT3< T >::BoxT3 ( const VectorT3< T > *  points,
const size_t  number 
)

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

Parameters
pointsThe points to be enclosed by the bounding box, must be valid
numberThe number of points, with range [1, infinity)

◆ BoxT3() [5/5]

template<typename T >
Ocean::BoxT3< T >::BoxT3 ( const VectorT3< T > &  center,
const T  xSize,
const T  ySize,
const T  zSize 
)

Creates a new bounding box with defined dimensions centered at a given 3D location.

Parameters
centerThe center position of the new bounding box, with range (-infinity, infinity)x(-infinity, infinity)x(-infinity, infinity)
xSizeThe size of the bounding box in the x-axis, with range [0, infinity)
ySizeThe size of the bounding box in the y-axis, with range [0, infinity)
zSizeThe size of the bounding box in the z-axis, with range [0, infinity)

Member Function Documentation

◆ center()

template<typename T >
VectorT3<T> Ocean::BoxT3< T >::center ( ) const

Returns the center of the box.

Returns
Box center

◆ clear()

template<typename T >
void Ocean::BoxT3< T >::clear ( )

Clears and resets the bounding box to an invalid box.

◆ corners()

template<typename T >
unsigned int Ocean::BoxT3< T >::corners ( VectorT3< T > *  corners) const

Returns the corner positions of this box.

If this box is planar the four points are returned only.

Parameters
cornersResulting corners, must provide space for at least eight points
Returns
Number of resulting corners

◆ diagonal()

template<typename T >
T Ocean::BoxT3< T >::diagonal ( ) const

Returns the diagonal of this box.

Returns
Box diagonal

◆ dimension()

template<typename T >
VectorT3<T> Ocean::BoxT3< T >::dimension ( ) const

Returns the dimension of this box for all three axis.

Returns
The box's dimension

◆ expand()

template<typename T >
BoxT3<T>& Ocean::BoxT3< T >::expand ( const VectorT3< T > &  offsets)

Expands this box.

Positive offsets will increase the box, negative offsets will decrease the box; offsets smaller than the dimension are clamped to zero.

Parameters
offsetsThe offsets along all three axis, an offset of +/-1 makes the box 1 unit larger/smaller, with range (-infinity, infinity)x(-infinity, infinity)x(-infinity, infinity)
Returns
Reference to this box

◆ expanded()

template<typename T >
BoxT3<T> Ocean::BoxT3< T >::expanded ( const VectorT3< T > &  offsets) const

Returns an expanded box of this box.

Positive offsets will increase the box, negative offsets will decrease the box; offsets smaller than the dimension are clamped to zero.

Parameters
offsetsThe offsets along all three axis, an offset of +/-1 makes the box 1 unit larger/smaller, with range (-infinity, infinity)x(-infinity, infinity)x(-infinity, infinity)
Returns
The new expanded box

◆ hasIntersection() [1/3]

template<typename T >
bool Ocean::BoxT3< T >::hasIntersection ( const LineT3< T > &  ray) const

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

Parameters
rayThe ray to be tested, must be valid
Returns
True, if so

◆ hasIntersection() [2/3]

template<typename T >
bool Ocean::BoxT3< T >::hasIntersection ( const LineT3< T > &  ray,
const HomogenousMatrixT4< T > &  box_T_ray 
) const

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

Parameters
rayThe ray to be tested, must be valid
box_T_rayThe transformation between ray and box, must be valid
Returns
True, if so

◆ hasIntersection() [3/3]

template<typename T >
bool Ocean::BoxT3< T >::hasIntersection ( const LineT3< T > &  ray,
const T  epsPerDistance 
) const

Returns whether a given ray has an intersection with this box while applying a distance-dependent epsilon threshold.

The larger the distance between the ray's origin and the box, the bigger the applied epsilon threshold.

Parameters
rayThe ray to be tested, must be valid
epsPerDistanceThe epsilon for distance 1 which will be multiplied with the (approximated) distance to determine the actual epsilon to be used, with range [0, infinity)
Returns
True, if so

◆ higher()

template<typename T >
const VectorT3<T>& Ocean::BoxT3< T >::higher ( ) const

Returns the higher corner of the box.

Returns
Higher corner

◆ isEqual()

template<typename T >
bool Ocean::BoxT3< T >::isEqual ( const BoxT3< T > &  box,
const T  epsilon = NumericT< T >::eps() 
) const

Returns whether two box objects are equal up to an epsilon.

Parameters
boxThe Box to compare with, can be invalid
epsilonThe accuracy epsilon, with range [0, infinity)
Returns
True, if so

◆ isInside()

template<typename T >
bool Ocean::BoxT3< T >::isInside ( const VectorT3< T > &  point,
const T  eps = T(0) 
) const

Returns whether a given point is inside this bounding box.

Parameters
pointThe point to check
epsThe optional epsilon adding an additional thin tolerance boundary, with range [0, infinity)
Returns
True, if so

◆ isOnSurface()

template<typename T >
bool Ocean::BoxT3< T >::isOnSurface ( const VectorT3< T > &  point,
const T  epsilon = NumericT< T >::eps() 
) const

Returns whether a given point lies on the surface of this box.

Parameters
pointThe point to be checked
epsilonThe accuracy value allowing some tolerance, with range [0, infinity)
Returns
True, if so

◆ isPlanar()

template<typename T >
bool Ocean::BoxT3< T >::isPlanar ( PlaneT3< T > &  plane) const

Returns whether this box is planar aligned to one axis.

A planar box has no expansion in one axis.

Parameters
planeThe plane the box is part of
Returns
True, if so

◆ isPoint()

template<typename T >
bool Ocean::BoxT3< T >::isPoint ( VectorT3< T > *  point = nullptr) const

Returns whether this box defines one single point only.

Parameters
pointOptional resulting point defined by the box
Returns
True, if so

◆ isValid()

template<typename T >
bool Ocean::BoxT3< T >::isValid ( ) const

Returns whether the bounding box is valid.

Returns
True, if so

◆ lower()

template<typename T >
const VectorT3<T>& Ocean::BoxT3< T >::lower ( ) const

Returns the lower corner of the box.

Returns
Lower corner

◆ operator bool()

template<typename T >
Ocean::BoxT3< T >::operator bool ( ) const

Returns whether this box is not a default box.

Returns
True, if so

◆ operator!=()

template<typename T >
bool Ocean::BoxT3< T >::operator!= ( const BoxT3< T > &  right) const

Returns whether two boxes are not identical.

Parameters
rightSecond box object
Returns
True, if so

◆ operator*() [1/2]

template<typename T >
BoxT3<T> Ocean::BoxT3< T >::operator* ( const HomogenousMatrixT4< T > &  world_T_box) const

Returns the (axis-aligned) world bounding box for a given transformation between the box and world.

Parameters
world_T_boxThe transformation between box and world, must be valid
Returns
The new (still) axis-aligned bounding box, defined in world, most likely the new box will have a larger volume than this box

◆ operator*() [2/2]

template<typename T >
BoxT3<T> Ocean::BoxT3< T >::operator* ( const T  factor) const

Returns an enlarged bounding box of this one.

Parameters
factorThe factor to enlarge the bounding box in each dimension, with range (-infinity, infinity)
Returns
New enlarged bounding box

◆ operator*=() [1/2]

template<typename T >
BoxT3<T>& Ocean::BoxT3< T >::operator*= ( const HomogenousMatrixT4< T > &  world_T_box)

Transforms this bounding box with a given transformation so that the this bounding box is defined in world afterwards.

Parameters
world_T_boxThe transformation between box and world, must be valid
Returns
Reference to this new bounding box now defined in world

◆ operator*=() [2/2]

template<typename T >
BoxT3<T>& Ocean::BoxT3< T >::operator*= ( const T  factor)

Enlarges the bounding box by a given factor in each dimension.

Parameters
factorThe factor to enlarge the bounding box in each dimension, with range (-infinity, infinity)
Returns
Reference to this (enlarged) bounding box

◆ operator+()

template<typename T >
BoxT3<T> Ocean::BoxT3< T >::operator+ ( const BoxT3< T > &  right) const

Returns the union of two bounding boxes.

Parameters
rightThe right bounding box
Returns
New joined bounding box

◆ operator+=() [1/2]

template<typename T >
BoxT3<T>& Ocean::BoxT3< T >::operator+= ( const BoxT3< T > &  right)

Joins to bounding boxes.

Parameters
rightThe right bounding box to join
Returns
Reference to this (joined) bounding box

◆ operator+=() [2/2]

template<typename T >
BoxT3<T>& Ocean::BoxT3< T >::operator+= ( const VectorT3< T > &  point)

Adds a new point to this bounding box and updates it's dimension.

Parameters
pointThe point to add to the bounding box
Returns
Reference to this bounding box

◆ operator==()

template<typename T >
bool Ocean::BoxT3< T >::operator== ( const BoxT3< T > &  right) const

Returns whether two boxes are identical.

Parameters
rightSecond box object
Returns
True, if so

◆ sqrDiagonal()

template<typename T >
T Ocean::BoxT3< T >::sqrDiagonal ( ) const

Returns the square diagonal of this box.

Returns
Square diagonal

◆ xDimension()

template<typename T >
T Ocean::BoxT3< T >::xDimension ( ) const

Returns the dimension in x axis, which could e.g.

be the width of this box. Beware: The result is undefined for an invalid box.

Returns
Dimension in x axis

◆ yDimension()

template<typename T >
T Ocean::BoxT3< T >::yDimension ( ) const

Returns the dimension in y axis, which could e.g.

be the height of this box. Beware: The result is undefined for an invalid box.

Returns
Dimension in y axis

◆ zDimension()

template<typename T >
T Ocean::BoxT3< T >::zDimension ( ) const

Returns the dimension in z axis, which could e.g.

be the depth of this box. Beware: The result is undefined for an invalid box.

Returns
Dimension in z axis

Field Documentation

◆ higher_

template<typename T >
VectorT3<T> Ocean::BoxT3< T >::higher_ = VectorT3<T>(NumericT<T>::minValue(), NumericT<T>::minValue(), NumericT<T>::minValue())
protected

Higher corner of the bounding box.

◆ lower_

template<typename T >
VectorT3<T> Ocean::BoxT3< T >::lower_ = VectorT3<T>(NumericT<T>::maxValue(), NumericT<T>::maxValue(), NumericT<T>::maxValue())
protected

Lower corner of the bounding box.


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