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

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

#include <jet/bounding_box2.h>

Public Member Functions

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

Public Attributes

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

Detailed Description

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

2-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, 2 >::BoundingBox ( )

Default constructor.

◆ BoundingBox() [2/3]

template<typename T >
jet::BoundingBox< T, 2 >::BoundingBox ( const Vector2< T > &  point1,
const Vector2< T > &  point2 
)

Constructs a box that tightly covers two points.

◆ BoundingBox() [3/3]

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

Constructs a box with other box instance.

Member Function Documentation

◆ clamp()

template<typename T >
Vector2<T> jet::BoundingBox< T, 2 >::clamp ( const Vector2< T > &  pt) const

Returns the clamped point.

◆ closestIntersection()

template<typename T >
BoundingBoxRayIntersection2<T> jet::BoundingBox< T, 2 >::closestIntersection ( const Ray2< 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, 2 >::contains ( const Vector2< T > &  point) const

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

◆ corner()

template<typename T >
Vector2<T> jet::BoundingBox< T, 2 >::corner ( size_t  idx) const

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

◆ diagonalLength()

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

Returns diagonal length of this box.

◆ diagonalLengthSquared()

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

Returns squared diagonal length of this box.

◆ expand()

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

template<typename T >
T jet::BoundingBox< T, 2 >::height ( ) const

Returns height of the box.

◆ intersects()

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

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

◆ isEmpty()

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

Returns true if the box is empty.

◆ length()

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

Returns length of the box in given axis.

◆ merge() [1/2]

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

Merges this and other box.

◆ merge() [2/2]

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

Merges this and other point.

◆ midPoint()

template<typename T >
Vector2<T> jet::BoundingBox< T, 2 >::midPoint ( ) const

Returns the mid-point of this box.

◆ overlaps()

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

Returns true of this box and other box overlaps.

◆ reset()

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

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

◆ width()

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

Returns width of the box.

Member Data Documentation

◆ lowerCorner

template<typename T >
Vector2<T> jet::BoundingBox< T, 2 >::lowerCorner

Lower corner of the bounding box.

◆ upperCorner

template<typename T >
Vector2<T> jet::BoundingBox< T, 2 >::upperCorner

Upper corner of the bounding box.


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