Jet  v1.3.3
Public Member Functions | Public Attributes | List of all members
jet::BoundingBox< T, 3 > Class Template Reference

3-D axis-aligned bounding box class. More...

#include <jet/bounding_box3.h>

Public Member Functions

 BoundingBox ()
 Default constructor. More...
 
 BoundingBox (const Vector3< T > &point1, const Vector3< T > &point2)
 Constructs a box that tightly covers two points. More...
 
 BoundingBox (const BoundingBox &other)
 Constructs a box with other box instance. More...
 
T width () const
 Returns width of the box. More...
 
T height () const
 Returns height of the box. More...
 
T 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 Vector3< T > &point) const
 Returns true if the input vector is inside of this box. More...
 
bool intersects (const Ray3< T > &ray) const
 Returns true if the input ray is intersecting with this box. More...
 
BoundingBoxRayIntersection3< T > closestIntersection (const Ray3< T > &ray) const
 
Vector3< T > 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 Vector3< T > &point)
 Merges this and other point. More...
 
void merge (const BoundingBox &other)
 Merges this and other box. More...
 
void expand (T delta)
 
Vector3< T > corner (size_t idx) const
 Returns corner position. Index starts from x-first order. More...
 
Vector3< T > clamp (const Vector3< T > &point) const
 Returns the clamped point. More...
 
bool isEmpty () const
 Returns true if the box is empty. More...
 

Public Attributes

Vector3< T > lowerCorner
 Lower corner of the bounding box. More...
 
Vector3< T > upperCorner
 Upper corner of the bounding box. More...
 

Detailed Description

template<typename T>
class jet::BoundingBox< T, 3 >

3-D axis-aligned bounding box class.

Template Parameters
T- Real number type.
N- Dimension.

Constructor & Destructor Documentation

◆ BoundingBox() [1/3]

template<typename T >
jet::BoundingBox< T, 3 >::BoundingBox ( )

Default constructor.

◆ BoundingBox() [2/3]

template<typename T >
jet::BoundingBox< T, 3 >::BoundingBox ( const Vector3< T > &  point1,
const Vector3< T > &  point2 
)

Constructs a box that tightly covers two points.

◆ BoundingBox() [3/3]

template<typename T >
jet::BoundingBox< T, 3 >::BoundingBox ( const BoundingBox< T, 3 > &  other)

Constructs a box with other box instance.

Member Function Documentation

◆ clamp()

template<typename T >
Vector3<T> jet::BoundingBox< T, 3 >::clamp ( const Vector3< T > &  point) const

Returns the clamped point.

◆ closestIntersection()

template<typename T >
BoundingBoxRayIntersection3<T> jet::BoundingBox< T, 3 >::closestIntersection ( const Ray3< T > &  ray) const

Returns intersection.isIntersecting = true if the input ray is intersecting with this box. If interesects, intersection.tNear is assigned with distant to the closest intersecting point, and intersection.tFar with furthest.

◆ contains()

template<typename T >
bool jet::BoundingBox< T, 3 >::contains ( const Vector3< T > &  point) const

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

◆ corner()

template<typename T >
Vector3<T> jet::BoundingBox< T, 3 >::corner ( size_t  idx) const

Returns corner position. Index starts from x-first order.

◆ depth()

template<typename T >
T jet::BoundingBox< T, 3 >::depth ( ) const

Returns depth of the box.

◆ diagonalLength()

template<typename T >
T jet::BoundingBox< T, 3 >::diagonalLength ( ) const

Returns diagonal length of this box.

◆ diagonalLengthSquared()

template<typename T >
T jet::BoundingBox< T, 3 >::diagonalLengthSquared ( ) const

Returns squared diagonal length of this box.

◆ expand()

template<typename T >
void jet::BoundingBox< T, 3 >::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 >
T jet::BoundingBox< T, 3 >::height ( ) const

Returns height of the box.

◆ intersects()

template<typename T >
bool jet::BoundingBox< T, 3 >::intersects ( const Ray3< T > &  ray) const

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

◆ isEmpty()

template<typename T >
bool jet::BoundingBox< T, 3 >::isEmpty ( ) const

Returns true if the box is empty.

◆ length()

template<typename T >
T jet::BoundingBox< T, 3 >::length ( size_t  axis)

Returns length of the box in given axis.

◆ merge() [1/2]

template<typename T >
void jet::BoundingBox< T, 3 >::merge ( const BoundingBox< T, 3 > &  other)

Merges this and other box.

◆ merge() [2/2]

template<typename T >
void jet::BoundingBox< T, 3 >::merge ( const Vector3< T > &  point)

Merges this and other point.

◆ midPoint()

template<typename T >
Vector3<T> jet::BoundingBox< T, 3 >::midPoint ( ) const

Returns the mid-point of this box.

◆ overlaps()

template<typename T >
bool jet::BoundingBox< T, 3 >::overlaps ( const BoundingBox< T, 3 > &  other) const

Returns true of this box and other box overlaps.

◆ reset()

template<typename T >
void jet::BoundingBox< T, 3 >::reset ( )

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

◆ width()

template<typename T >
T jet::BoundingBox< T, 3 >::width ( ) const

Returns width of the box.

Member Data Documentation

◆ lowerCorner

template<typename T >
Vector3<T> jet::BoundingBox< T, 3 >::lowerCorner

Lower corner of the bounding box.

◆ upperCorner

template<typename T >
Vector3<T> jet::BoundingBox< T, 3 >::upperCorner

Upper corner of the bounding box.


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