N-D axis-aligned bounding box class. More...
#include <Core/Geometry/BoundingBox.hpp>
Public Types | |
using | VectorType = Vector< T, N > |
using | RayType = Ray< T, N > |
Public Member Functions | |
BoundingBox () | |
Default constructor. More... | |
BoundingBox (const VectorType &point1, const VectorType &point2) | |
Constructs a box that tightly covers two points. More... | |
~BoundingBox ()=default | |
Default destructor. More... | |
BoundingBox (const BoundingBox &other) | |
Constructs a box with other box instance. More... | |
BoundingBox (BoundingBox &&other) noexcept | |
Constructs a box with other box instance. More... | |
BoundingBox & | operator= (const BoundingBox &other) |
Copy assignment operator. More... | |
BoundingBox & | operator= (BoundingBox &&other) noexcept |
Move assignment operator. More... | |
T | Width () const |
Returns width of the box. More... | |
template<typename U = T> | |
std::enable_if_t<(N > 1), U > | Height () const |
Returns height of the box. More... | |
template<typename U = T> | |
std::enable_if_t<(N > 2), U > | Depth () const |
Returns depth of the box. More... | |
T | Length (size_t axis) |
Returns length of the box in given axis. More... | |
bool | Overlaps (const BoundingBox &other) const |
Returns true of this box and other box overlaps. More... | |
bool | Contains (const VectorType &point) const |
Returns true if the input vector is inside of this box. More... | |
bool | Intersects (const RayType &ray) const |
Returns true if the input ray is intersecting with this box. More... | |
BoundingBoxRayIntersection< T > | ClosestIntersection (const RayType &ray) const |
VectorType | MidPoint () const |
Returns the mid-point of this box. More... | |
T | DiagonalLength () const |
Returns diagonal length of this box. More... | |
T | DiagonalLengthSquared () const |
Returns squared diagonal length of this box. More... | |
void | Reset () |
Resets this box to initial state (min=infinite, max=-infinite). More... | |
void | Merge (const VectorType &point) |
Merges this and other point. More... | |
void | Merge (const BoundingBox &other) |
Merges this and other box. More... | |
void | Expand (T delta) |
VectorType | Corner (size_t idx) const |
Returns corner position. Index starts from x-first order. More... | |
VectorType | Clamp (const VectorType &point) const |
Returns the clamped point. More... | |
bool | IsEmpty () const |
Returns true if the box is empty. More... | |
template<typename U > | |
BoundingBox< U, N > | CastTo () const |
Returns box with different value type. More... | |
template<typename U > | |
std::enable_if_t<(N > 1), U > | Height () const |
template<typename U > | |
std::enable_if_t<(N > 2), U > | Depth () const |
Public Attributes | |
VectorType | lowerCorner |
Lower corner of the bounding box. More... | |
VectorType | upperCorner |
Upper corner of the bounding box. More... | |
Detailed Description
template<typename T, size_t N>
class CubbyFlow::BoundingBox< T, N >
N-D axis-aligned bounding box class.
- Template Parameters
-
T Real number type. N Dimension.
Member Typedef Documentation
◆ RayType
using CubbyFlow::BoundingBox< T, N >::RayType = Ray<T, N> |
◆ VectorType
using CubbyFlow::BoundingBox< T, N >::VectorType = Vector<T, N> |
Constructor & Destructor Documentation
◆ BoundingBox() [1/4]
CubbyFlow::BoundingBox< T, N >::BoundingBox | ( | ) |
Default constructor.
◆ BoundingBox() [2/4]
CubbyFlow::BoundingBox< T, N >::BoundingBox | ( | const VectorType & | point1, |
const VectorType & | point2 | ||
) |
Constructs a box that tightly covers two points.
◆ ~BoundingBox()
|
default |
Default destructor.
◆ BoundingBox() [3/4]
CubbyFlow::BoundingBox< T, N >::BoundingBox | ( | const BoundingBox< T, N > & | other | ) |
Constructs a box with other box instance.
◆ BoundingBox() [4/4]
|
noexcept |
Constructs a box with other box instance.
Member Function Documentation
◆ CastTo()
BoundingBox< U, N > CubbyFlow::BoundingBox< T, N >::CastTo | ( | ) | const |
Returns box with different value type.
◆ Clamp()
BoundingBox< T, N >::VectorType CubbyFlow::BoundingBox< T, N >::Clamp | ( | const VectorType & | point | ) | const |
Returns the clamped point.
◆ ClosestIntersection()
BoundingBoxRayIntersection< T > CubbyFlow::BoundingBox< T, N >::ClosestIntersection | ( | const RayType & | ray | ) | const |
Returns intersection.isIntersecting = true if the input ray is intersecting with this box. If intersects, intersection.tNear is assigned with distant to the closest intersecting point, and intersection.tFar with furthest.
◆ Contains()
bool CubbyFlow::BoundingBox< T, N >::Contains | ( | const VectorType & | point | ) | const |
Returns true if the input vector is inside of this box.
◆ Corner()
BoundingBox< T, N >::VectorType CubbyFlow::BoundingBox< T, N >::Corner | ( | size_t | idx | ) | const |
Returns corner position. Index starts from x-first order.
◆ Depth() [1/2]
std::enable_if_t<(N > 2), U> CubbyFlow::BoundingBox< T, N >::Depth | ( | ) | const |
◆ Depth() [2/2]
std::enable_if_t<(N > 2), U> CubbyFlow::BoundingBox< T, N >::Depth | ( | ) | const |
Returns depth of the box.
◆ DiagonalLength()
T CubbyFlow::BoundingBox< T, N >::DiagonalLength | ( | ) | const |
Returns diagonal length of this box.
◆ DiagonalLengthSquared()
T CubbyFlow::BoundingBox< T, N >::DiagonalLengthSquared | ( | ) | const |
Returns squared diagonal length of this box.
◆ Expand()
void CubbyFlow::BoundingBox< T, N >::Expand | ( | T | delta | ) |
Expands this box by given delta to all direction. If the width of the box was x, expand(y) will result a box with x+y+y width.
◆ Height() [1/2]
std::enable_if_t<(N > 1), U> CubbyFlow::BoundingBox< T, N >::Height | ( | ) | const |
◆ Height() [2/2]
std::enable_if_t<(N > 1), U> CubbyFlow::BoundingBox< T, N >::Height | ( | ) | const |
Returns height of the box.
◆ Intersects()
bool CubbyFlow::BoundingBox< T, N >::Intersects | ( | const RayType & | ray | ) | const |
Returns true if the input ray is intersecting with this box.
◆ IsEmpty()
bool CubbyFlow::BoundingBox< T, N >::IsEmpty | ( | ) | const |
Returns true if the box is empty.
◆ Length()
T CubbyFlow::BoundingBox< T, N >::Length | ( | size_t | axis | ) |
Returns length of the box in given axis.
◆ Merge() [1/2]
void CubbyFlow::BoundingBox< T, N >::Merge | ( | const VectorType & | point | ) |
Merges this and other point.
◆ Merge() [2/2]
void CubbyFlow::BoundingBox< T, N >::Merge | ( | const BoundingBox< T, N > & | other | ) |
Merges this and other box.
◆ MidPoint()
BoundingBox< T, N >::VectorType CubbyFlow::BoundingBox< T, N >::MidPoint | ( | ) | const |
Returns the mid-point of this box.
◆ operator=() [1/2]
BoundingBox< T, N > & CubbyFlow::BoundingBox< T, N >::operator= | ( | const BoundingBox< T, N > & | other | ) |
Copy assignment operator.
◆ operator=() [2/2]
|
noexcept |
Move assignment operator.
◆ Overlaps()
bool CubbyFlow::BoundingBox< T, N >::Overlaps | ( | const BoundingBox< T, N > & | other | ) | const |
Returns true of this box and other box overlaps.
◆ Reset()
void CubbyFlow::BoundingBox< T, N >::Reset | ( | ) |
Resets this box to initial state (min=infinite, max=-infinite).
◆ Width()
T CubbyFlow::BoundingBox< T, N >::Width | ( | ) | const |
Returns width of the box.
Member Data Documentation
◆ lowerCorner
VectorType CubbyFlow::BoundingBox< T, N >::lowerCorner |
Lower corner of the bounding box.
◆ upperCorner
VectorType CubbyFlow::BoundingBox< T, N >::upperCorner |
Upper corner of the bounding box.
The documentation for this class was generated from the following files:
- Core/Geometry/BoundingBox.hpp
- Core/Geometry/BoundingBox-Impl.hpp