CubbyFlow::BoundingBox< T, N > Class Template Reference

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...
 
BoundingBoxoperator= (const BoundingBox &other)
 Copy assignment operator. More...
 
BoundingBoxoperator= (BoundingBox &&other) noexcept
 Move assignment operator. More...
 
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...
 
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...
 
DiagonalLength () const
 Returns diagonal length of this box. More...
 
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
TReal number type.
NDimension.

Member Typedef Documentation

◆ RayType

template<typename T, size_t N>
using CubbyFlow::BoundingBox< T, N >::RayType = Ray<T, N>

◆ VectorType

template<typename T, size_t N>
using CubbyFlow::BoundingBox< T, N >::VectorType = Vector<T, N>

Constructor & Destructor Documentation

◆ BoundingBox() [1/4]

template<typename T , size_t N>
CubbyFlow::BoundingBox< T, N >::BoundingBox ( )

Default constructor.

◆ BoundingBox() [2/4]

template<typename T , size_t N>
CubbyFlow::BoundingBox< T, N >::BoundingBox ( const VectorType point1,
const VectorType point2 
)

Constructs a box that tightly covers two points.

◆ ~BoundingBox()

template<typename T, size_t N>
CubbyFlow::BoundingBox< T, N >::~BoundingBox ( )
default

Default destructor.

◆ BoundingBox() [3/4]

template<typename T , size_t N>
CubbyFlow::BoundingBox< T, N >::BoundingBox ( const BoundingBox< T, N > &  other)

Constructs a box with other box instance.

◆ BoundingBox() [4/4]

template<typename T , size_t N>
CubbyFlow::BoundingBox< T, N >::BoundingBox ( BoundingBox< T, N > &&  other)
noexcept

Constructs a box with other box instance.

Member Function Documentation

◆ CastTo()

template<typename T , size_t N>
template<typename U >
BoundingBox< U, N > CubbyFlow::BoundingBox< T, N >::CastTo ( ) const

Returns box with different value type.

◆ Clamp()

template<typename T , size_t N>
BoundingBox< T, N >::VectorType CubbyFlow::BoundingBox< T, N >::Clamp ( const VectorType point) const

Returns the clamped point.

◆ ClosestIntersection()

template<typename T , size_t N>
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()

template<typename T , size_t N>
bool CubbyFlow::BoundingBox< T, N >::Contains ( const VectorType point) const

Returns true if the input vector is inside of this box.

◆ Corner()

template<typename T , size_t N>
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]

template<typename T, size_t N>
template<typename U >
std::enable_if_t<(N > 2), U> CubbyFlow::BoundingBox< T, N >::Depth ( ) const

◆ Depth() [2/2]

template<typename T, size_t N>
template<typename U = T>
std::enable_if_t<(N > 2), U> CubbyFlow::BoundingBox< T, N >::Depth ( ) const

Returns depth of the box.

◆ DiagonalLength()

template<typename T , size_t N>
T CubbyFlow::BoundingBox< T, N >::DiagonalLength ( ) const

Returns diagonal length of this box.

◆ DiagonalLengthSquared()

template<typename T , size_t N>
T CubbyFlow::BoundingBox< T, N >::DiagonalLengthSquared ( ) const

Returns squared diagonal length of this box.

◆ Expand()

template<typename T, size_t N>
void CubbyFlow::BoundingBox< T, N >::Expand ( 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]

template<typename T, size_t N>
template<typename U >
std::enable_if_t<(N > 1), U> CubbyFlow::BoundingBox< T, N >::Height ( ) const

◆ Height() [2/2]

template<typename T, size_t N>
template<typename U = T>
std::enable_if_t<(N > 1), U> CubbyFlow::BoundingBox< T, N >::Height ( ) const

Returns height of the box.

◆ Intersects()

template<typename T , size_t N>
bool CubbyFlow::BoundingBox< T, N >::Intersects ( const RayType ray) const

Returns true if the input ray is intersecting with this box.

◆ IsEmpty()

template<typename T , size_t N>
bool CubbyFlow::BoundingBox< T, N >::IsEmpty ( ) const

Returns true if the box is empty.

◆ Length()

template<typename T , size_t N>
T CubbyFlow::BoundingBox< T, N >::Length ( size_t  axis)

Returns length of the box in given axis.

◆ Merge() [1/2]

template<typename T , size_t N>
void CubbyFlow::BoundingBox< T, N >::Merge ( const VectorType point)

Merges this and other point.

◆ Merge() [2/2]

template<typename T , size_t N>
void CubbyFlow::BoundingBox< T, N >::Merge ( const BoundingBox< T, N > &  other)

Merges this and other box.

◆ MidPoint()

template<typename T , size_t N>
BoundingBox< T, N >::VectorType CubbyFlow::BoundingBox< T, N >::MidPoint ( ) const

Returns the mid-point of this box.

◆ operator=() [1/2]

template<typename T , size_t N>
BoundingBox< T, N > & CubbyFlow::BoundingBox< T, N >::operator= ( const BoundingBox< T, N > &  other)

Copy assignment operator.

◆ operator=() [2/2]

template<typename T , size_t N>
BoundingBox< T, N > & CubbyFlow::BoundingBox< T, N >::operator= ( BoundingBox< T, N > &&  other)
noexcept

Move assignment operator.

◆ Overlaps()

template<typename T , size_t N>
bool CubbyFlow::BoundingBox< T, N >::Overlaps ( const BoundingBox< T, N > &  other) const

Returns true of this box and other box overlaps.

◆ Reset()

template<typename T , size_t N>
void CubbyFlow::BoundingBox< T, N >::Reset ( )

Resets this box to initial state (min=infinite, max=-infinite).

◆ Width()

template<typename T , size_t N>
T CubbyFlow::BoundingBox< T, N >::Width ( ) const

Returns width of the box.

Member Data Documentation

◆ lowerCorner

template<typename T, size_t N>
VectorType CubbyFlow::BoundingBox< T, N >::lowerCorner

Lower corner of the bounding box.

◆ upperCorner

template<typename T, size_t N>
VectorType CubbyFlow::BoundingBox< T, N >::upperCorner

Upper corner of the bounding box.


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