Ocean
|
This class implements an axis aligned 3D bounding box. More...
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 > ¢er, 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... | |
T | sqrDiagonal () const |
Returns the square diagonal of this box. More... | |
T | diagonal () const |
Returns the diagonal of this box. More... | |
T | xDimension () const |
Returns the dimension in x axis, which could e.g. More... | |
T | yDimension () const |
Returns the dimension in y axis, which could e.g. More... | |
T | 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... | |
This class implements an axis aligned 3D bounding box.
T | The data type of the scalar to be used, either 'float' or 'double' |
|
default |
Creates an invalid bounding box.
Ocean::BoxT3< T >::BoxT3 | ( | const VectorT3< T > & | lower, |
const VectorT3< T > & | higher | ||
) |
Creates a new bounding box by two given corners.
lower | The lower corner |
higher | The higher corner |
|
explicit |
Creates a new bounding box enclosing a given set of 3D points.
points | The points to be enclosed by the bounding box |
Ocean::BoxT3< T >::BoxT3 | ( | const VectorT3< T > * | points, |
const size_t | number | ||
) |
Creates a new bounding box enclosing a given set of 3D points.
points | The points to be enclosed by the bounding box, must be valid |
number | The number of points, with range [1, infinity) |
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.
center | The center position of the new bounding box, with range (-infinity, infinity)x(-infinity, infinity)x(-infinity, infinity) |
xSize | The size of the bounding box in the x-axis, with range [0, infinity) |
ySize | The size of the bounding box in the y-axis, with range [0, infinity) |
zSize | The size of the bounding box in the z-axis, with range [0, infinity) |
VectorT3<T> Ocean::BoxT3< T >::center | ( | ) | const |
Returns the center of the box.
void Ocean::BoxT3< T >::clear | ( | ) |
Clears and resets the bounding box to an invalid box.
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.
corners | Resulting corners, must provide space for at least eight points |
T Ocean::BoxT3< T >::diagonal | ( | ) | const |
Returns the diagonal of this box.
VectorT3<T> Ocean::BoxT3< T >::dimension | ( | ) | const |
Returns the dimension of this box for all three axis.
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.
offsets | The 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) |
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.
offsets | The 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) |
bool Ocean::BoxT3< T >::hasIntersection | ( | const LineT3< T > & | ray | ) | const |
Returns whether a given ray has an intersection with this box.
ray | The ray to be tested, must be valid |
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.
ray | The ray to be tested, must be valid |
box_T_ray | The transformation between ray and box, must be valid |
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.
ray | The ray to be tested, must be valid |
epsPerDistance | The epsilon for distance 1 which will be multiplied with the (approximated) distance to determine the actual epsilon to be used, with range [0, infinity) |
const VectorT3<T>& Ocean::BoxT3< T >::higher | ( | ) | const |
Returns the higher corner of the box.
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.
box | The Box to compare with, can be invalid |
epsilon | The accuracy epsilon, with range [0, infinity) |
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.
point | The point to check |
eps | The optional epsilon adding an additional thin tolerance boundary, with range [0, infinity) |
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.
point | The point to be checked |
epsilon | The accuracy value allowing some tolerance, with range [0, infinity) |
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.
plane | The plane the box is part of |
bool Ocean::BoxT3< T >::isPoint | ( | VectorT3< T > * | point = nullptr | ) | const |
Returns whether this box defines one single point only.
point | Optional resulting point defined by the box |
bool Ocean::BoxT3< T >::isValid | ( | ) | const |
Returns whether the bounding box is valid.
const VectorT3<T>& Ocean::BoxT3< T >::lower | ( | ) | const |
Returns the lower corner of the box.
Ocean::BoxT3< T >::operator bool | ( | ) | const |
Returns whether this box is not a default box.
bool Ocean::BoxT3< T >::operator!= | ( | const BoxT3< T > & | right | ) | const |
Returns whether two boxes are not identical.
right | Second box object |
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.
world_T_box | The transformation between box and world, must be valid |
BoxT3<T> Ocean::BoxT3< T >::operator* | ( | const T | factor | ) | const |
Returns an enlarged bounding box of this one.
factor | The factor to enlarge the bounding box in each dimension, with range (-infinity, infinity) |
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.
world_T_box | The transformation between box and world, must be valid |
BoxT3<T>& Ocean::BoxT3< T >::operator*= | ( | const T | factor | ) |
Enlarges the bounding box by a given factor in each dimension.
factor | The factor to enlarge the bounding box in each dimension, with range (-infinity, infinity) |
BoxT3<T> Ocean::BoxT3< T >::operator+ | ( | const BoxT3< T > & | right | ) | const |
Returns the union of two bounding boxes.
right | The right bounding box |
BoxT3<T>& Ocean::BoxT3< T >::operator+= | ( | const BoxT3< T > & | right | ) |
Joins to bounding boxes.
right | The right bounding box to join |
BoxT3<T>& Ocean::BoxT3< T >::operator+= | ( | const VectorT3< T > & | point | ) |
Adds a new point to this bounding box and updates it's dimension.
point | The point to add to the bounding box |
bool Ocean::BoxT3< T >::operator== | ( | const BoxT3< T > & | right | ) | const |
Returns whether two boxes are identical.
right | Second box object |
T Ocean::BoxT3< T >::sqrDiagonal | ( | ) | const |
Returns the square diagonal of this box.
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.
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.
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.
|
protected |
Higher corner of the bounding box.
|
protected |
Lower corner of the bounding box.