Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | List of all members
shammath::AABB< T > Struct Template Reference

Axis-Aligned bounding box. More...

#include <shammath/include/shammath/AABB.hpp>

+ Collaboration diagram for shammath::AABB< T >:

Public Types

using T_prop = shambase::VectorProperties< T >
 Properties of the coordinates type.
 
using Tscal = typename T_prop::component_type
 Scalar type of the coordinates.
 

Public Member Functions

 AABB (T lower, T upper)
 Construct an AABB from lower and upper bounds.
 
 AABB (std::tuple< T, T > range)
 Construct an AABB from a tuple of lower and upper bounds.
 
 AABB (std::pair< T, T > range)
 Construct an AABB from a pair of lower and upper bounds.
 
delt () const
 Returns the delta of the AABB.
 
Tscal get_radius () const
 
Tscal get_volume ()
 Returns the volume of the AABB.
 
get_center () const noexcept
 Returns the center of the AABB.
 
sum_bounds () const noexcept
 Returns the sum of the lower and upper bounds of the AABB.
 
AABB expand_all (Tscal value)
 Expand the AABB by a given value on all dimensions.
 
template<class Tb >
AABB< Tb > convert ()
 Converts the AABB to a different type.
 
AABB get_intersect (AABB other) const noexcept
 Compute the intersection of two AABB.
 
bool contains (AABB other) const noexcept
 Check if AABB fully contains another AABB.
 
bool contains_asymmetric (T point) const noexcept
 Check if point is in AABB using half-open interval [lower, upper)
 
bool is_not_empty () const noexcept
 Checks if the AABB is non-empty.
 
bool is_volume_not_null () const noexcept
 Checks if the AABB has a non-zero volume.
 
bool is_surface () const noexcept
 Checks if the AABB is a surface.
 
bool is_surface_or_volume () const noexcept
 Checks if the AABB is a surface or a volume.
 
clamp_coord (T coord) const noexcept
 Clamp a coordinate to the box.
 
bool intersect_ray (Ray< T > ray) const noexcept
 Check if the ray intersect the AABB.
 
bool intersect_ring_ray_approx (RingRay< T > ring_ray) const noexcept
 Check if the ring ray intersect the AABB.
 
bool operator== (const AABB< T > &other) const noexcept
 equal operator
 
bool operator!= (const AABB< T > &other) const noexcept
 not equal operator
 

Public Attributes

lower
 Lower bound of the AABB.
 
upper
 Upper bound of the AABB.
 

Detailed Description

template<class T>
struct shammath::AABB< T >

Axis-Aligned bounding box.

This class describe a bounding box aligned on the axis.

This class describe a domain of coordinates defined by a cartesian product of 1d ranges. For example : [ax,bx] x [ay,by] x [az,bz]

Template Parameters
TType of the coordinates

Definition at line 99 of file AABB.hpp.

Member Typedef Documentation

◆ T_prop

template<class T >
using shammath::AABB< T >::T_prop = shambase::VectorProperties<T>

Properties of the coordinates type.

Definition at line 101 of file AABB.hpp.

◆ Tscal

template<class T >
using shammath::AABB< T >::Tscal = typename T_prop::component_type

Scalar type of the coordinates.

Definition at line 102 of file AABB.hpp.

Constructor & Destructor Documentation

◆ AABB() [1/3]

template<class T >
shammath::AABB< T >::AABB ( lower,
upper 
)
inline

Construct an AABB from lower and upper bounds.

This constructor takes the lower and upper bounds of the AABB, and constructs an AABB object from them.

Parameters
lowerThe lower bound of the AABB
upperThe upper bound of the AABB

Definition at line 118 of file AABB.hpp.

◆ AABB() [2/3]

template<class T >
shammath::AABB< T >::AABB ( std::tuple< T, T >  range)
inline

Construct an AABB from a tuple of lower and upper bounds.

This constructor takes a tuple of lower and upper bounds, and constructs an AABB object from them.

Parameters
rangeA tuple of lower and upper bounds

Definition at line 131 of file AABB.hpp.

◆ AABB() [3/3]

template<class T >
shammath::AABB< T >::AABB ( std::pair< T, T >  range)
inline

Construct an AABB from a pair of lower and upper bounds.

This constructor takes a pair of lower and upper bounds, and constructs an AABB object from them.

Parameters
rangeA pair of lower and upper bounds

Definition at line 142 of file AABB.hpp.

Member Function Documentation

◆ clamp_coord()

template<class T >
T shammath::AABB< T >::clamp_coord ( coord) const
inlinenoexcept

Clamp a coordinate to the box.

This function clamp a coordinate to the box defined by the AABB. It return the clamped value.

Parameters
[in]coordThe coordinate to clamp
Returns
the clamped value

Definition at line 320 of file AABB.hpp.

◆ contains()

template<class T >
bool shammath::AABB< T >::contains ( AABB< T >  other) const
inlinenoexcept

Check if AABB fully contains another AABB.

Parameters
otherAABB to check for containment
Returns
true if this AABB fully contains other

Definition at line 244 of file AABB.hpp.

◆ contains_asymmetric()

template<class T >
bool shammath::AABB< T >::contains_asymmetric ( point) const
inlinenoexcept

Check if point is in AABB using half-open interval [lower, upper)

Parameters
pointPoint to test
Returns
true if point is in [lower, upper)

Definition at line 256 of file AABB.hpp.

◆ convert()

template<class T >
template<class Tb >
AABB< Tb > shammath::AABB< T >::convert ( )
inline

Converts the AABB to a different type.

This function converts the current AABB to a new AABB with a different coordinate type, specified by the template parameter Tb. The conversion is performed for both the lower and upper bounds of the AABB.

Template Parameters
TbThe target coordinate type for conversion.
Returns
A new AABB object with the converted coordinate type.
Note
The dimension of the AABB must remain the same during conversion.

Definition at line 213 of file AABB.hpp.

◆ delt()

template<class T >
T shammath::AABB< T >::delt ( ) const
inline

Returns the delta of the AABB.

This function returns the delta of the AABB, which is the difference between the upper and lower bounds of the AABB.

Returns
The delta of the AABB

Definition at line 152 of file AABB.hpp.

◆ expand_all()

template<class T >
AABB shammath::AABB< T >::expand_all ( Tscal  value)
inline

Expand the AABB by a given value on all dimensions.

This function expands the AABB by the given value on all dimensions. The lower bound is shifted down by the given value, and the upper bound is shifted up by the given value.

Parameters
valueThe value to expand the AABB by.
Returns
A new AABB with the expanded bounds.

Definition at line 197 of file AABB.hpp.

◆ get_center()

template<class T >
T shammath::AABB< T >::get_center ( ) const
inlinenoexcept

Returns the center of the AABB.

This function returns the center of the AABB, which is the average of the lower and upper bounds of the AABB.

Returns
The center of the AABB

Definition at line 174 of file AABB.hpp.

◆ get_intersect()

template<class T >
AABB shammath::AABB< T >::get_intersect ( AABB< T >  other) const
inlinenoexcept

Compute the intersection of two AABB.

This function return a new AABB which is the intersection of the two AABB. The intersection of two AABB is defined as the biggest AABB that is contained in both AABB.

Parameters
otherThe other AABB
Returns
The intersection of the two AABB

Definition at line 234 of file AABB.hpp.

◆ get_radius()

template<class T >
Tscal shammath::AABB< T >::get_radius ( ) const
inline

Definition at line 154 of file AABB.hpp.

◆ get_volume()

template<class T >
Tscal shammath::AABB< T >::get_volume ( )
inline

Returns the volume of the AABB.

This function returns the volume of the AABB, which is the product of the differences between the upper and lower bounds of the AABB for each axis.

Returns
The volume of the AABB

Definition at line 164 of file AABB.hpp.

◆ intersect_ray()

template<class T >
bool shammath::AABB< T >::intersect_ray ( Ray< T >  ray) const
inlinenoexcept

Check if the ray intersect the AABB.

This function perform a ray-AABB intersection test. It return true if the ray intersect the AABB and false otherwise.

Parameters
[in]rayThe ray to test
Returns
true if the ray intersect the AABB

Definition at line 356 of file AABB.hpp.

+ Here is the call graph for this function:

◆ intersect_ring_ray_approx()

template<class T >
bool shammath::AABB< T >::intersect_ring_ray_approx ( RingRay< T >  ring_ray) const
inlinenoexcept

Check if the ring ray intersect the AABB.

This function perform a ring ray-AABB intersection test. It return true if the ring ray intersect the AABB and false otherwise.

Parameters
[in]ring_rayThe ring ray to test
Returns
true if the ring ray intersect the AABB

Definition at line 381 of file AABB.hpp.

◆ is_not_empty()

template<class T >
bool shammath::AABB< T >::is_not_empty ( ) const
inlinenoexcept

Checks if the AABB is non-empty.

This function determines if the axis-aligned bounding box (AABB) has a non-zero volume by comparing its upper and lower bounds.

Returns
true if the AABB is non-empty, false otherwise.

Definition at line 268 of file AABB.hpp.

◆ is_surface()

template<class T >
bool shammath::AABB< T >::is_surface ( ) const
inlinenoexcept

Checks if the AABB is a surface.

This function determines if the axis-aligned bounding box (AABB) is a surface. A surface is an AABB where only one of its dimensions have a non-zero size.

Returns
true if the AABB is a surface, false otherwise.

Definition at line 293 of file AABB.hpp.

+ Here is the call graph for this function:

◆ is_surface_or_volume()

template<class T >
bool shammath::AABB< T >::is_surface_or_volume ( ) const
inlinenoexcept

Checks if the AABB is a surface or a volume.

This function determines if the axis-aligned bounding box (AABB) is a surface or a volume. A surface is an AABB where only one of its dimensions have a non-zero size. A volume is an AABB where all its dimensions have a non-zero size.

Returns
true if the AABB is a surface or a volume, false otherwise.

Definition at line 307 of file AABB.hpp.

+ Here is the call graph for this function:

◆ is_volume_not_null()

template<class T >
bool shammath::AABB< T >::is_volume_not_null ( ) const
inlinenoexcept

Checks if the AABB has a non-zero volume.

This function is more strict than is_not_empty() and checks if the AABB has a non-zero volume by comparing its upper and lower bounds.

Returns
true if the AABB has a non-zero volume, false otherwise.

Definition at line 280 of file AABB.hpp.

◆ operator!=()

template<class T >
bool shammath::AABB< T >::operator!= ( const AABB< T > &  other) const
inlinenoexcept

not equal operator

Definition at line 352 of file AABB.hpp.

◆ operator==()

template<class T >
bool shammath::AABB< T >::operator== ( const AABB< T > &  other) const
inlinenoexcept

equal operator

Definition at line 347 of file AABB.hpp.

◆ sum_bounds()

template<class T >
T shammath::AABB< T >::sum_bounds ( ) const
inlinenoexcept

Returns the sum of the lower and upper bounds of the AABB.

This function returns the sum of the lower and upper bounds of the AABB. This is useful for some algorithms, like the one used in the BVH tree.

Returns
The sum of the lower and upper bounds of the AABB

Definition at line 184 of file AABB.hpp.

Member Data Documentation

◆ lower

template<class T >
T shammath::AABB< T >::lower

Lower bound of the AABB.

Definition at line 104 of file AABB.hpp.

◆ upper

template<class T >
T shammath::AABB< T >::upper

Upper bound of the AABB.

Definition at line 105 of file AABB.hpp.


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