Loading...
Searching...
No Matches
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.
 
 BoundingBox (const VectorType &point1, const VectorType &point2)
 Constructs a box that tightly covers two points.
 
 ~BoundingBox ()=default
 Default destructor.
 
 BoundingBox (const BoundingBox &other)
 Constructs a box with other box instance.
 
 BoundingBox (BoundingBox &&other) noexcept
 Constructs a box with other box instance.
 
BoundingBoxoperator= (const BoundingBox &other)
 Copy assignment operator.
 
BoundingBoxoperator= (BoundingBox &&other) noexcept
 Move assignment operator.
 
T Width () const
 Returns width of the box.
 
template<typename U = T>
std::enable_if_t<(N > 1), U > Height () const
 Returns height of the box.
 
template<typename U = T>
std::enable_if_t<(N > 2), U > Depth () const
 Returns depth of the box.
 
T Length (size_t axis)
 Returns length of the box in given axis.
 
bool Overlaps (const BoundingBox &other) const
 Returns true of this box and other box overlaps.
 
bool Contains (const VectorType &point) const
 Returns true if the input vector is inside of this box.
 
bool Intersects (const RayType &ray) const
 Returns true if the input ray is intersecting with this box.
 
BoundingBoxRayIntersection< TClosestIntersection (const RayType &ray) const
 
VectorType MidPoint () const
 Returns the mid-point of this box.
 
T DiagonalLength () const
 Returns diagonal length of this box.
 
T DiagonalLengthSquared () const
 Returns squared diagonal length of this box.
 
void Reset ()
 Resets this box to initial state (min=infinite, max=-infinite).
 
void Merge (const VectorType &point)
 Merges this and other point.
 
void Merge (const BoundingBox &other)
 Merges this and other box.
 
void Expand (T delta)
 
VectorType Corner (size_t idx) const
 Returns corner position. Index starts from x-first order.
 
VectorType Clamp (const VectorType &point) const
 Returns the clamped point.
 
bool IsEmpty () const
 Returns true if the box is empty.
 
template<typename U >
BoundingBox< U, NCastTo () const
 Returns box with different value type.
 

Public Attributes

VectorType lowerCorner
 Lower corner of the bounding box.
 
VectorType upperCorner
 Upper corner of the bounding box.
 

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()

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

template<typename T , size_t N>
template<typename U >
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 BoundingBox< T, N > &  other)

Merges this and other box.

◆ Merge() [2/2]

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

Merges this and other point.

◆ 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= ( BoundingBox< T, N > &&  other)
noexcept

Move assignment operator.

◆ operator=() [2/2]

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

Copy 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: