EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
EBGeometry::BoundingVolumes::AABBT< T > Class Template Reference

Axis-aligned bounding box (AABB) enclosing a set of 3D points. More...

#include <EBGeometry_BoundingVolumes.hpp>

Public Types

using Vec3 = Vec3T< T >
 Alias to cut down on typing.
 

Public Member Functions

 AABBT () noexcept=default
 Default constructor. Sets lo = +∞, hi = −∞ (inverted sentinel).
 
 AABBT (const Vec3T< T > &a_lo, const Vec3T< T > &a_hi) noexcept
 Construct an AABB from explicit low and high corners.
 
 AABBT (const AABBT &a_other) noexcept
 Copy constructor.
 
 AABBT (const std::vector< AABBT< T > > &a_others) noexcept
 Construct the smallest AABB enclosing all boxes in a_others.
 
template<class P >
 AABBT (const std::vector< Vec3T< P > > &a_points) noexcept
 Construct the smallest AABB enclosing a set of 3D points.
 
 ~AABBT () noexcept
 Destructor.
 
AABBToperator= (const AABBT< T > &a_other)=default
 Copy assignment.
 
 AABBT (AABBT &&a_other) noexcept=default
 Move constructor.
 
AABBToperator= (AABBT &&a_other) noexcept=default
 Move assignment operator.
 
template<class P >
void define (const std::vector< Vec3T< P > > &a_points) noexcept
 Fit this AABB to the smallest box enclosing a_points.
 
bool intersects (const AABBT &a_other) const noexcept
 Test whether this AABB intersects a_other.
 
Vec3T< T > & getLowCorner () noexcept
 Get a modifiable reference to the low corner of the AABB.
 
const Vec3T< T > & getLowCorner () const noexcept
 Get the low corner of the AABB.
 
Vec3T< T > & getHighCorner () noexcept
 Get a modifiable reference to the high corner of the AABB.
 
const Vec3T< T > & getHighCorner () const noexcept
 Get the high corner of the AABB.
 
Vec3 getCentroid () const noexcept
 Compute the centroid of the AABB.
 
getOverlappingVolume (const AABBT< T > &a_other) const noexcept
 Compute the overlapping volume between this AABB and a_other.
 
getDistance (const Vec3 &a_x0) const noexcept
 Compute the unsigned distance from a_x0 to this AABB.
 
getDistance2 (const Vec3 &a_x0) const noexcept
 Compute the squared unsigned distance from a_x0 to this AABB.
 
getVolume () const noexcept
 Compute the AABB volume.
 
getArea () const noexcept
 Compute the AABB surface area.
 

Protected Attributes

Vec3 m_loCorner = Vec3::infinity()
 Low corner of the bounding box. Initialised to +∞ (inverted sentinel).
 
Vec3 m_hiCorner = -Vec3::infinity()
 High corner of the bounding box. Initialised to −∞ (inverted sentinel).
 

Friends

std::ostream & operator<< (std::ostream &os, const AABBT< T > &aabb)
 Output an AABB to a stream in the form "(lo, hi)".
 

Detailed Description

template<class T>
class EBGeometry::BoundingVolumes::AABBT< T >

Axis-aligned bounding box (AABB) enclosing a set of 3D points.

Template Parameters
TFloating-point precision (e.g., float or double).

Constructor & Destructor Documentation

◆ AABBT() [1/6]

template<class T >
EBGeometry::BoundingVolumes::AABBT< T >::AABBT ( )
defaultnoexcept

Default constructor. Sets lo = +∞, hi = −∞ (inverted sentinel).

The inverted state is the identity element for AABB union and also ensures that any geometric query (distance, volume, intersection) fires an EBGEOMETRY_EXPECT assertion. Call define() or use the explicit constructor before use.

◆ AABBT() [2/6]

template<class T >
EBGeometry::BoundingVolumes::AABBT< T >::AABBT ( const Vec3T< T > &  a_lo,
const Vec3T< T > &  a_hi 
)
inlinenoexcept

Construct an AABB from explicit low and high corners.

Parameters
[in]a_loLow corner.
[in]a_hiHigh corner.

◆ AABBT() [3/6]

template<class T >
EBGeometry::BoundingVolumes::AABBT< T >::AABBT ( const AABBT< T > &  a_other)
inlinenoexcept

Copy constructor.

Parameters
[in]a_otherBounding box to copy.

◆ AABBT() [4/6]

template<class T >
EBGeometry::BoundingVolumes::AABBT< T >::AABBT ( const std::vector< AABBT< T > > &  a_others)
inlinenoexcept

Construct the smallest AABB enclosing all boxes in a_others.

Parameters
[in]a_othersBounding boxes to enclose.

◆ AABBT() [5/6]

template<class T >
template<class P >
EBGeometry::BoundingVolumes::AABBT< T >::AABBT ( const std::vector< Vec3T< P > > &  a_points)
inlinenoexcept

Construct the smallest AABB enclosing a set of 3D points.

Mixed floating-point precision is allowed: P may differ from T.

Template Parameters
PFloating-point precision of the input points.
Parameters
[in]a_pointsSet of 3D points.

◆ AABBT() [6/6]

template<class T >
EBGeometry::BoundingVolumes::AABBT< T >::AABBT ( AABBT< T > &&  a_other)
defaultnoexcept

Move constructor.

Parameters
[in]a_otherBounding box to move from.

Member Function Documentation

◆ define()

template<class T >
template<class P >
void EBGeometry::BoundingVolumes::AABBT< T >::define ( const std::vector< Vec3T< P > > &  a_points)
inlinenoexcept

Fit this AABB to the smallest box enclosing a_points.

Mixed floating-point precision is allowed: P may differ from T.

Template Parameters
PFloating-point precision of the input points.
Parameters
[in]a_pointsSet of 3D points.

◆ getArea()

template<class T >
T EBGeometry::BoundingVolumes::AABBT< T >::getArea ( ) const
inlinenoexcept

Compute the AABB surface area.

Returns
Sum of the six face areas: 2*(dx*dy + dy*dz + dz*dx).

◆ getCentroid()

template<class T >
Vec3 EBGeometry::BoundingVolumes::AABBT< T >::getCentroid ( ) const
inlinenoexcept

Compute the centroid of the AABB.

Returns
Midpoint of the low and high corners.

◆ getDistance()

template<class T >
T EBGeometry::BoundingVolumes::AABBT< T >::getDistance ( const Vec3 a_x0) const
inlinenoexcept

Compute the unsigned distance from a_x0 to this AABB.

Parameters
[in]a_x03D query point.
Returns
Distance from a_x0 to the nearest box face; zero if a_x0 is inside.

◆ getDistance2()

template<class T >
T EBGeometry::BoundingVolumes::AABBT< T >::getDistance2 ( const Vec3 a_x0) const
inlinenoexcept

Compute the squared unsigned distance from a_x0 to this AABB.

Avoids the sqrt that getDistance() pays – prefer this whenever the caller only needs the distance for comparison (e.g. BVH pruning), not its actual magnitude.

Parameters
[in]a_x03D query point.
Returns
Squared distance from a_x0 to the nearest box face; zero if a_x0 is inside.

◆ getHighCorner() [1/2]

template<class T >
const Vec3T< T > & EBGeometry::BoundingVolumes::AABBT< T >::getHighCorner ( ) const
inlinenoexcept

Get the high corner of the AABB.

Returns
Const reference to the high corner.

◆ getHighCorner() [2/2]

template<class T >
Vec3T< T > & EBGeometry::BoundingVolumes::AABBT< T >::getHighCorner ( )
inlinenoexcept

Get a modifiable reference to the high corner of the AABB.

Returns
Reference to the high corner.

◆ getLowCorner() [1/2]

template<class T >
const Vec3T< T > & EBGeometry::BoundingVolumes::AABBT< T >::getLowCorner ( ) const
inlinenoexcept

Get the low corner of the AABB.

Returns
Const reference to the low corner.

◆ getLowCorner() [2/2]

template<class T >
Vec3T< T > & EBGeometry::BoundingVolumes::AABBT< T >::getLowCorner ( )
inlinenoexcept

Get a modifiable reference to the low corner of the AABB.

Returns
Reference to the low corner.

◆ getOverlappingVolume()

template<class T >
T EBGeometry::BoundingVolumes::AABBT< T >::getOverlappingVolume ( const AABBT< T > &  a_other) const
inlinenoexcept

Compute the overlapping volume between this AABB and a_other.

Parameters
[in]a_otherThe other AABB.
Returns
Overlap volume; zero if the boxes do not intersect.

◆ getVolume()

template<class T >
T EBGeometry::BoundingVolumes::AABBT< T >::getVolume ( ) const
inlinenoexcept

Compute the AABB volume.

Returns
Product of the three side lengths: dx * dy * dz.

◆ intersects()

template<class T >
bool EBGeometry::BoundingVolumes::AABBT< T >::intersects ( const AABBT< T > &  a_other) const
inlinenoexcept

Test whether this AABB intersects a_other.

Parameters
[in]a_otherThe other AABB.
Returns
True if the two boxes overlap, false otherwise.

◆ operator=() [1/2]

template<class T >
AABBT & EBGeometry::BoundingVolumes::AABBT< T >::operator= ( AABBT< T > &&  a_other)
defaultnoexcept

Move assignment operator.

Parameters
[in]a_otherBounding box to move from.
Returns
Reference to (*this).

◆ operator=() [2/2]

template<class T >
AABBT & EBGeometry::BoundingVolumes::AABBT< T >::operator= ( const AABBT< T > &  a_other)
default

Copy assignment.

Parameters
[in]a_otherBounding box to copy.
Returns
Reference to (*this).

Friends And Related Symbol Documentation

◆ operator<<

template<class T >
std::ostream & operator<< ( std::ostream &  os,
const AABBT< T > &  aabb 
)
friend

Output an AABB to a stream in the form "(lo, hi)".

Parameters
[in,out]osOutput stream.
[in]aabbBounding box to print.
Returns
Reference to os to allow chaining.

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