AABBtree  0.0.0
A C++ non-recursive ND AABB tree
Loading...
Searching...
No Matches
AABBtree::Box< Real, N > Class Template Reference

A class representing an axis-aligned bounding box (AABB) in N-dimensional space. More...

#include <Box.hxx>

Public Types

enum class  Side : Integer { LEFT = -1 , INSIDE = 0 , RIGHT = +1 }
 

Public Member Functions

 ~Box ()=default
 
 Box ()
 
 Box (Box const &b)
 
 Box (Point const &t_min, Point const &t_max)
 
 Box (Point const &p)
 
template<typename = std::enable_if<N == 1>>
 Box (Real const x_min, Real const x_max)
 
template<typename = std::enable_if<N == 2>>
 Box (Real const x_min, Real const y_min, Real const x_max, Real const y_max)
 
template<typename = std::enable_if<N == 3>>
 Box (Real const x_min, Real const y_min, Real const z_min, Real const x_max, Real const y_max, Real const z_max)
 
template<typename OtherReal>
 Box (Box< OtherReal, N > const &b)
 
Boxoperator= (Box const &b)=default
 
template<typename NewReal>
Box< NewReal, N > cast () const
 
Point const & min () const
 
Pointmin ()
 
Point const & max () const
 
Pointmax ()
 
void reorder ()
 
bool is_empty () const
 
bool is_approx (Box const &b, Real const tol) const
 
bool is_degenerate (Real const tol) const
 
Integer longest_axis () const
 
Integer longest_axis (Real &max_length, Real &mid_point) const
 
void sort_axes_length (Vector &sizes, Eigen::Vector< Integer, N > &ipos) const
 
Point baricenter () const
 
Real baricenter (Integer i) const
 
Real volume () const
 
Real surface () const
 
Vector diagonal () const
 
void set_degenerate (Point const &p)
 
void set_empty ()
 
bool intersects (Box const &b) const
 
bool intersect (Box const &b_in, Box &b_out) const
 
Box merged (Box const &b) const
 
Boxtranslate (Vector const &t)
 
Box translated (Vector const &t) const
 
template<typename Transform>
Box transformed (Transform const &t) const
 
template<typename Transform>
Boxtransform (Transform const &t)
 
Side which_side (Real const x, Real const tol, Integer const dim) const
 
bool contains (Point const &p) const
 
bool intersects (Point const &p) const
 
bool contains (Box const &b) const
 
template<typename Derived>
Boxextend (Point const &p)
 
Boxextend (Box const &b)
 
Real squared_interior_distance (Point const &p) const
 
Real squared_interior_distance (Point const &p, Point &c) const
 
Real interior_distance (Point const &p) const
 
Real interior_distance (Point const &p, Point &c) const
 
Real squared_exterior_distance (Point const &p) const
 
Real squared_exterior_distance (Point const &p, Point &f) const
 
Real exterior_distance (Point const &p) const
 
Real exterior_distance (Point const &p, Point &f) const
 
Real squared_interior_distance (Box const &b) const
 
Real squared_interior_distance (Box const &b, Point &p1, Point &p2) const
 
Real interior_distance (Box const &b) const
 
Real interior_distance (Box const &b, Point &p1, Point &p2) const
 
Real squared_exterior_distance (Box const &b) const
 
Real squared_exterior_distance (Box const &b, Point &p1, Point &p2) const
 
Real exterior_distance (Box const &b) const
 
Real exterior_distance (Box const &b, Point &p1, Point &p2) const
 
bool intersects (Ray< Real, N > const &r, Real tol=DUMMY_TOL) const
 
bool intersect (Ray< Real, N > const &r, Point &c, Point &f, Real tol=DUMMY_TOL) const
 
Real squared_interior_distance (Ray< Real, N > const &r, Real tol=DUMMY_TOL) const
 
Real squared_interior_distance (Ray< Real, N > const &r, Point &p1, Point &p2, Real tol=DUMMY_TOL) const
 
Real interior_distance (Ray< Real, N > const &r, Real tol=DUMMY_TOL) const
 
Real interior_distance (Ray< Real, N > const &r, Point &p1, Point &p2, Real tol=DUMMY_TOL) const
 
Real squared_exterior_distance (Ray< Real, N > const &r, Real tol=DUMMY_TOL) const
 
Real squared_exterior_distance (Ray< Real, N > const &r, Point &p1, Point &p2, Real tol=DUMMY_TOL) const
 
Real exterior_distance (Ray< Real, N > const &r, Real tol=DUMMY_TOL) const
 
Real exterior_distance (Ray< Real, N > const &r, Point &p1, Point &p2, Real tol=DUMMY_TOL) const
 
void print (std::ostream &os) const
 

Private Types

using Point = AABBtree::Point<Real, N>
 
using Vector = AABBtree::Vector<Real, N>
 
using BoxUniquePtr = AABBtree::BoxUniquePtr<Real, N>
 
using BoxUniquePtrList = AABBtree::BoxUniquePtrList<Real, N>
 

Private Attributes

Point m_min
 
Point m_max
 

Static Private Attributes

static constexpr Real EPS {std::numeric_limits<Real>::epsilon()}
 
static constexpr Real INF {std::numeric_limits<Real>::infinity()}
 
static constexpr Real DUMMY_TOL {EPS*static_cast<Real>(100.0)}
 

Detailed Description

template<typename Real, Integer N>
class AABBtree::Box< Real, N >

This class represents an axis-aligned bounding box (AABB) defined by two opposite corners:

  • Minimum corner (lower bounds in all dimensions);
  • Maximum corner (upper bounds in all dimensions).

The Box class provides various geometric operations including:

  • Intersection and containment tests;
  • Distance calculations;
  • Transformation operations;
  • Volume and surface area computations.
Template Parameters
RealFloating-point scalar type (must be float or double).
NDimension of the ambient space.
Note
The box is considered empty if any component of the minimum corner is greater than the corresponding component of the maximum corner.
All methods are thread-safe unless explicitly noted otherwise.

Member Typedef Documentation

◆ BoxUniquePtr

template<typename Real, Integer N>
using AABBtree::Box< Real, N >::BoxUniquePtr = AABBtree::BoxUniquePtr<Real, N>
private

◆ BoxUniquePtrList

template<typename Real, Integer N>
using AABBtree::Box< Real, N >::BoxUniquePtrList = AABBtree::BoxUniquePtrList<Real, N>
private

◆ Point

template<typename Real, Integer N>
using AABBtree::Box< Real, N >::Point = AABBtree::Point<Real, N>
private

◆ Vector

template<typename Real, Integer N>
using AABBtree::Box< Real, N >::Vector = AABBtree::Vector<Real, N>
private

Member Enumeration Documentation

◆ Side

template<typename Real, Integer N>
enum class AABBtree::Box::Side : Integer
strong

Enumeration for relative position with respect to the box.

Enumerator
LEFT -1 
INSIDE 
RIGHT +1 

Constructor & Destructor Documentation

◆ ~Box()

template<typename Real, Integer N>
AABBtree::Box< Real, N >::~Box ( )
default

Class destructor for the axis-aligned box.

◆ Box() [1/8]

template<typename Real, Integer N>
AABBtree::Box< Real, N >::Box ( )
inline

Default constructor creating an empty box whether the minimal and maximal corners are set to the maximum and minimum representable values, respectively.

◆ Box() [2/8]

template<typename Real, Integer N>
AABBtree::Box< Real, N >::Box ( Box< Real, N > const & b)
inline

Copy constructor for a axis-aligned box given another box.

Parameters
[in]bBox to copy.

◆ Box() [3/8]

template<typename Real, Integer N>
AABBtree::Box< Real, N >::Box ( Point const & t_min,
Point const & t_max )
inline

Class constructor for a axis-aligned box given the minimal and maximal corners.

Parameters
[in]t_minMinimal corner of the box.
[in]t_maxMaximal corner of the box.
Warning
If the reordering is not performed, and the minimal corner is greater than the maximal corner in any dimension, undefined behavior may occur.

◆ Box() [4/8]

template<typename Real, Integer N>
AABBtree::Box< Real, N >::Box ( Point const & p)
inline

Class constructor for a axis-aligned box containing a single point.

Parameters
[in]pPoint to be contained in the box.

◆ Box() [5/8]

template<typename Real, Integer N>
template<typename = std::enable_if<N == 1>>
AABBtree::Box< Real, N >::Box ( Real const x_min,
Real const x_max )
inline

Class constructor for the 1D axis-aligned bounding box.

Parameters
[in]x_minMinimal \( x \)-axis corner of the box.
[in]x_maxMaximal \( x \)-axis corner of the box.
Template Parameters
TType of the scalar coefficients.
Note
This constructor is only available for 1D boxes.

◆ Box() [6/8]

template<typename Real, Integer N>
template<typename = std::enable_if<N == 2>>
AABBtree::Box< Real, N >::Box ( Real const x_min,
Real const y_min,
Real const x_max,
Real const y_max )
inline

Class constructor for the 2D axis-aligned bounding box.

Parameters
[in]x_minMinimal \( x \)-axis corner of the box.
[in]y_minMinimal \( y \)-axis corner of the box.
[in]x_maxMaximal \( x \)-axis corner of the box.
[in]y_maxMaximal \( y \)-axis corner of the box.
Template Parameters
TType of the scalar coefficients.
Note
This constructor is only available for 2D boxes.

◆ Box() [7/8]

template<typename Real, Integer N>
template<typename = std::enable_if<N == 3>>
AABBtree::Box< Real, N >::Box ( Real const x_min,
Real const y_min,
Real const z_min,
Real const x_max,
Real const y_max,
Real const z_max )
inline

Class constructor for the 3D axis-aligned bounding box.

Parameters
[in]x_minMinimal \( x \)-axis corner of the box.
[in]y_minMinimal \( y \)-axis corner of the box.
[in]z_minMinimal \( z \)-axis corner of the box.
[in]x_maxMaximal \( x \)-axis corner of the box.
[in]y_maxMaximal \( y \)-axis corner of the box.
[in]z_maxMaximal \( z \)-axis corner of the box.
Template Parameters
TType of the scalar coefficients.
Note
This constructor is only available for 3D boxes.

◆ Box() [8/8]

template<typename Real, Integer N>
template<typename OtherReal>
AABBtree::Box< Real, N >::Box ( Box< OtherReal, N > const & b)
inlineexplicit

Copy constructor for a axis-aligned box given another box with a different scalar type.

Parameters
[in]bBox to copy.
Template Parameters
OtherRealType of the scalar coefficients of the box to copy.

Member Function Documentation

◆ baricenter() [1/2]

template<typename Real, Integer N>
Point AABBtree::Box< Real, N >::baricenter ( ) const
inline

Compute the barycenter of the box.

Returns
Point at the center of the box.

◆ baricenter() [2/2]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::baricenter ( Integer i) const
inline

Compute the barycenter coordinate along a specific dimension.

Parameters
[in]iDimension index.
Returns
Barycenter coordinate along the i-thdimension.

◆ cast()

template<typename Real, Integer N>
template<typename NewReal>
Box< NewReal, N > AABBtree::Box< Real, N >::cast ( ) const
inline

Cast the current object to a new scalar type.

Template Parameters
NewRealthe new scalar type.
Note
If the new real type is equal to the current scalar type currently used, then this function returns a const reference to the current object.

◆ contains() [1/2]

template<typename Real, Integer N>
bool AABBtree::Box< Real, N >::contains ( Box< Real, N > const & b) const
inline

Check if this box completely contains another box.

Parameters
[in]bBox to check.
Returns
True if the box is entirely within this box, false otherwise.

◆ contains() [2/2]

template<typename Real, Integer N>
bool AABBtree::Box< Real, N >::contains ( Point const & p) const
inline

Check if a point is inside the box.

Parameters
[in]pPoint to check.
Returns
True if point is inside or on boundary, false otherwise.

◆ diagonal()

template<typename Real, Integer N>
Vector AABBtree::Box< Real, N >::diagonal ( ) const
inline

Compute the diagonal vector of the box.

Returns
Vector from minimum to maximal corner.
Note
For the length of the diagonal, use diagonal().norm() .

◆ extend() [1/2]

template<typename Real, Integer N>
Box & AABBtree::Box< Real, N >::extend ( Box< Real, N > const & b)
inline

Extend this box to contain another box.

Parameters
[in]bBox to include.
Returns
Reference to this box after extension.
Note
Merging with an empty box may result in a box bigger than *this .

◆ extend() [2/2]

template<typename Real, Integer N>
template<typename Derived>
Box & AABBtree::Box< Real, N >::extend ( Point const & p)
inline

Extend this box to contain a point.

Parameters
[in]pPoint to include.
Returns
Reference to this box after extension.

◆ exterior_distance() [1/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::exterior_distance ( Box< Real, N > const & b) const
inline

Compute the exterior (or maximum) distance between the current box a given box.

Parameters
[in]bBox to compute the distance to.
Returns
The distance between the boxes.
Note
The distance is positive if the boxes do not intersect, zero otherwise.

◆ exterior_distance() [2/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::exterior_distance ( Box< Real, N > const & b,
Point & p1,
Point & p2 ) const
inline

Compute the exterior (or maximum) distance between the current box a given box, and return two points at the maximum distance.

Parameters
[in]bBox to compute the distance to.
[out]p1First point at the maximum distance.
[out]p2Second point at the maximum distance.
Returns
The distance between the boxes.
Note
The distance is positive if the boxes do not intersect, zero otherwise.

◆ exterior_distance() [3/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::exterior_distance ( Point const & p) const
inline

Compute the exterior (or maximum) distance between the current box a given point.

Parameters
[in]pPoint to compute the distance to.
Returns
The distance between the box and the point.
Note
The distance is positive if the point is outside the box, zero otherwise.

◆ exterior_distance() [4/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::exterior_distance ( Point const & p,
Point & f ) const
inline

Compute the exterior (or maximum) distance between the current box a given point, returning a point at the given distance.

Parameters
[in]pPoint to compute the distance to.
[out]fFarthest point to the box.
Returns
The distance between the box and the point.
Note
The returned value is positive if the point is outside the box, zero otherwise.

◆ exterior_distance() [5/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::exterior_distance ( Ray< Real, N > const & r,
Point & p1,
Point & p2,
Real tol = DUMMY_TOL ) const
inline

Compute the exterior (or maximum) distance between the current box a given ray, and return two points at the maximum distance.

Parameters
[in]rRay to compute the distance to.
[out]p1First point at the maximum distance (on the current box).
[out]p2Second point at the maximum distance (on the ray).
[in]tolTolerance to use for the distance computation.
Returns
The distance between the ray and the box.
Note
The distance is positive if the ray and the box do not intersect, zero otherwise.

◆ exterior_distance() [6/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::exterior_distance ( Ray< Real, N > const & r,
Real tol = DUMMY_TOL ) const
inline

Compute the exterior (or maximum) distance between the current box a given ray.

Parameters
[in]rRay to compute the distance to.
[in]tolTolerance to use for the distance computation.
Returns
The distance between the ray and the box.
Note
The distance is positive if the ray and the box do not intersect, zero otherwise.

◆ interior_distance() [1/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::interior_distance ( Box< Real, N > const & b) const
inline

Compute the interior (or minimum) distance between the current box a given box.

Parameters
[in]bBox to compute the distance to.
Returns
The distance between the boxes.
Note
The distance is positive if the boxes do not intersect, zero otherwise.

◆ interior_distance() [2/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::interior_distance ( Box< Real, N > const & b,
Point & p1,
Point & p2 ) const
inline

Compute the interior (or minimum) distance between the current box a given box, returning two points at the minimum distance.

Parameters
[in]bBox to compute the distance to.
[out]p1First point at the minimum distance.
[out]p2Second point at the minimum distance.
Returns
The distance between the boxes.
Note
The distance is positive if the boxes do not intersect, zero otherwise.

◆ interior_distance() [3/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::interior_distance ( Point const & p) const
inline

Compute the interior (or minimum) distance between the current box a given point.

Parameters
[in]pPoint to compute the distance to.
Returns
The distance between the box and the point.
Note
The distance is positive if the point is outside the box, zero otherwise.

◆ interior_distance() [4/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::interior_distance ( Point const & p,
Point & c ) const
inline

Compute the interior (or minimum) distance between the current box a given point, returning a point at the given distance.

Parameters
[in]pPoint to compute the distance to.
[out]cClosest point to the box.
Returns
The distance between the box and the point.
Note
The returned value is positive if the point is outside the box, zero otherwise.

◆ interior_distance() [5/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::interior_distance ( Ray< Real, N > const & r,
Point & p1,
Point & p2,
Real tol = DUMMY_TOL ) const
inline

Compute the interior (or minimum) distance between the current box a given ray, returning two points at the minimum distance.

Parameters
[in]rRay to compute the distance to.
[out]p1First point at the minimum distance (on the current box).
[out]p2Second point at the minimum distance (on the ray).
[in]tolTolerance to use for the distance computation.
Returns
The distance between the ray and the box.
Note
The distance is positive if the ray and the box do not intersect, zero otherwise.

◆ interior_distance() [6/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::interior_distance ( Ray< Real, N > const & r,
Real tol = DUMMY_TOL ) const
inline

Compute the interior (or minimum) distance between the current box a given ray.

Parameters
[in]rRay to compute the distance to.
[in]tolTolerance to use for the distance computation.
Returns
The distance between the ray and the box.
Note
The distance is positive if the ray and the box do not intersect, zero otherwise.

◆ intersect() [1/2]

template<typename Real, Integer N>
bool AABBtree::Box< Real, N >::intersect ( Box< Real, N > const & b_in,
Box< Real, N > & b_out ) const
inline

Compute the intersection of this box with another box.

Parameters
[in]b_inBox to intersect with.
[out]b_outResulting intersection box.
Returns
True if intersection exists, false otherwise.

◆ intersect() [2/2]

template<typename Real, Integer N>
bool AABBtree::Box< Real, N >::intersect ( Ray< Real, N > const & r,
Point & c,
Point & f,
Real tol = DUMMY_TOL ) const
inline

Check if the current box intersects a given ray.

Parameters
[in]rRay to check.
[out]cClosest intersection point.
[out]fFarthest intersection point.
[in]tolTolerance to use for the intersection.
Returns
True if the current box intersects the given ray, false otherwise.

◆ intersects() [1/3]

template<typename Real, Integer N>
bool AABBtree::Box< Real, N >::intersects ( Box< Real, N > const & b) const
inline

Check if this box intersects with another box.

Parameters
[in]bBox to check for intersection.
Returns
True if boxes intersect, false otherwise.

◆ intersects() [2/3]

template<typename Real, Integer N>
bool AABBtree::Box< Real, N >::intersects ( Point const & p) const
inline

Check if a point intersects the box.

Parameters
[in]pPoint to check.
Returns
True if point is inside or on boundary, false otherwise.
Note
Equivalent to contains() for points.

◆ intersects() [3/3]

template<typename Real, Integer N>
bool AABBtree::Box< Real, N >::intersects ( Ray< Real, N > const & r,
Real tol = DUMMY_TOL ) const
inline

Check if the current box intersects a given ray.

Parameters
[in]rRay to check.
[in]tolTolerance to use for the intersection.
Returns
True if the current box intersects the given ray, false otherwise.

◆ is_approx()

template<typename Real, Integer N>
bool AABBtree::Box< Real, N >::is_approx ( Box< Real, N > const & b,
Real const tol ) const
inline

Check if this box is approximately equal to another box.

Parameters
[in]bBox to compare with.
[in]tolTolerance for the comparison.
Returns
True if boxes are approximately equal within tolerance.

◆ is_degenerate()

template<typename Real, Integer N>
bool AABBtree::Box< Real, N >::is_degenerate ( Real const tol) const
inline

Check if the current box is degenrate, i.e., it has zero volume.

Parameters
[in]tolTolerance to use for the comparison.
Returns
True if the box is degenerate, false otherwise.

◆ is_empty()

template<typename Real, Integer N>
bool AABBtree::Box< Real, N >::is_empty ( ) const
inline

Check if the box is empty, i.e., the minimal corner is greater than the maximal corner in any dimension.

Returns
True if the box is empty, false otherwise.

◆ longest_axis() [1/2]

template<typename Real, Integer N>
Integer AABBtree::Box< Real, N >::longest_axis ( ) const
inline

Find the longest axis of the box.

Returns
Index of the dimension with the largest extent.

◆ longest_axis() [2/2]

template<typename Real, Integer N>
Integer AABBtree::Box< Real, N >::longest_axis ( Real & max_length,
Real & mid_point ) const
inline

Find the longest axis and compute its length and midpoint.

Parameters
[out]max_lengthLength of the longest axis.
[out]mid_pointMidpoint of the longest axis.
Returns
Index of the dimension with the largest extent.

◆ max() [1/2]

template<typename Real, Integer N>
Point & AABBtree::Box< Real, N >::max ( )
inline

Get a non const reference to the maximal corner.

Returns
The maximal corner of the box.

◆ max() [2/2]

template<typename Real, Integer N>
Point const & AABBtree::Box< Real, N >::max ( ) const
inline

Get the maximal corner.

Returns
The maximal corner of the box.

◆ merged()

template<typename Real, Integer N>
Box AABBtree::Box< Real, N >::merged ( Box< Real, N > const & b) const
inline

Compute the union of this box with another box.

Parameters
[in]bBox to merge with.
Returns
The smallest box containing both boxes.

◆ min() [1/2]

template<typename Real, Integer N>
Point & AABBtree::Box< Real, N >::min ( )
inline

Get a non const reference to the minimal corner.

Returns
The minimal corner of the box.

◆ min() [2/2]

template<typename Real, Integer N>
Point const & AABBtree::Box< Real, N >::min ( ) const
inline

Get the minimal corner.

Returns
The minimal corner of the box.

◆ operator=()

template<typename Real, Integer N>
Box & AABBtree::Box< Real, N >::operator= ( Box< Real, N > const & b)
default

Assignment perator for a axis-aligned box given another box.

Parameters
[in]bBox to copy.
Returns
A reference to the current box.

◆ print()

template<typename Real, Integer N>
void AABBtree::Box< Real, N >::print ( std::ostream & os) const
inline

Print the box info to an output stream.

Parameters
[in]osOutput stream to print the box info to.

◆ reorder()

template<typename Real, Integer N>
void AABBtree::Box< Real, N >::reorder ( )
inline

Reorder the corners of the box such that the minimal corner is less than the maximal corner.

◆ set_degenerate()

template<typename Real, Integer N>
void AABBtree::Box< Real, N >::set_degenerate ( Point const & p)
inline

Set the box to be degenerate (containing a single point).

Parameters
[in]pPoint to set the box to.

◆ set_empty()

template<typename Real, Integer N>
void AABBtree::Box< Real, N >::set_empty ( )
inline

Set the box to be empty.

◆ sort_axes_length()

template<typename Real, Integer N>
void AABBtree::Box< Real, N >::sort_axes_length ( Vector & sizes,
Eigen::Vector< Integer, N > & ipos ) const
inline

Sort axes by their lengths in descending order.

Parameters
[out]sizesVector to store the sizes of each dimension.
[out]iposVector to store the sorted dimension indices.

◆ squared_exterior_distance() [1/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::squared_exterior_distance ( Box< Real, N > const & b) const
inline

Compute the squared exterior (or maximum) distance between the current box a given box.

Parameters
[in]bBox to compute the squared distance to.
Returns
The squared distance between the boxes.
Note
The squared distance is positive if one box is not contained in the other, zero otherwise.

◆ squared_exterior_distance() [2/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::squared_exterior_distance ( Box< Real, N > const & b,
Point & p1,
Point & p2 ) const
inline

Compute the squared exterior (or maximum) distance between the current box a given box, returning two points at the maximum distance.

Parameters
[in]bBox to compute the squared distance to.
[out]p1First point at the maximum distance.
[out]p2Second point at the maximum distance.
Returns
The squared distance between the boxes.

◆ squared_exterior_distance() [3/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::squared_exterior_distance ( Point const & p) const
inline

Compute the squared exterior (or maximum) distance between the current box a given point.

Parameters
[in]pPoint to compute the squared distance to.
Returns
The squared distance between the box and the point.
Note
The returned value is positive if the point is outside the box, zero otherwise.

◆ squared_exterior_distance() [4/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::squared_exterior_distance ( Point const & p,
Point & f ) const
inline

Compute the squared exterior (or maximum) distance between the current box a given point, returning a point at the given distance.

Parameters
[in]pPoint to compute the squared distance to.
[out]fFarthest point to the box.
Returns
The squared distance between the box and the point.
Note
The returned value is positive if the point is outside the box, zero otherwise.

◆ squared_exterior_distance() [5/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::squared_exterior_distance ( Ray< Real, N > const & r,
Point & p1,
Point & p2,
Real tol = DUMMY_TOL ) const
inline

Compute the squared exterior (or maximum) distance between the current box a given ray, returning two points at the maximum distance.

Parameters
[in]rRay to compute the squared distance to.
[out]p1First point at the maximum distance (on the current box).
[out]p2Second point at the maximum distance (on the ray).
[in]tolTolerance to use for the distance computation.
Returns
The squared distance between the ray and the box.

◆ squared_exterior_distance() [6/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::squared_exterior_distance ( Ray< Real, N > const & r,
Real tol = DUMMY_TOL ) const
inline

Compute the squared exterior (or maximum) distance between the current box a given ray.

Parameters
[in]rRay to compute the squared distance to.
[in]tolTolerance to use for the distance computation.
Returns
The squared distance between the ray and the box.
Note
The squared distance is positive if one box is not contained in the other, zero otherwise.

◆ squared_interior_distance() [1/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::squared_interior_distance ( Box< Real, N > const & b) const
inline

Compute the squared interior (or minimum) distance between the current box a given box.

Parameters
[in]bBox to compute the squared distance to.
Returns
The squared distance between the boxes.
Note
The squared distance is positive if the boxes do not intersect, zero otherwise.

◆ squared_interior_distance() [2/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::squared_interior_distance ( Box< Real, N > const & b,
Point & p1,
Point & p2 ) const
inline

Compute the squared interior (or minimum) distance between the current box a given box, returning two points at the minimum distance.

Parameters
[in]bBox to compute the squared distance to.
[out]p1First point at the minimum distance.
[out]p2Second point at the minimum distance.
Returns
The squared distance between the boxes.
Note
The squared distance is positive if the boxes do not intersect, zero otherwise.

◆ squared_interior_distance() [3/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::squared_interior_distance ( Point const & p) const
inline

Compute the squared interior (or minimum) distance between the current box a given point.

Parameters
[in]pPoint to compute the squared distance to.
Returns
The squared distance between the box and the point.
Note
The returned value is positive if the point is outside the box, zero otherwise.

◆ squared_interior_distance() [4/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::squared_interior_distance ( Point const & p,
Point & c ) const
inline

Compute the squared interior (or minimum) distance between the current box a given point, returning a point at the given distance.

Parameters
[in]pPoint to compute the squared distance to.
[out]cClosest point to the box.
Returns
The squared distance between the box and the point.
Note
The returned value is positive if the point is outside the box, zero otherwise.

◆ squared_interior_distance() [5/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::squared_interior_distance ( Ray< Real, N > const & r,
Point & p1,
Point & p2,
Real tol = DUMMY_TOL ) const
inline

Compute the squared interior (or minimum) distance between the current box a given ray, returning two points at the minimum distance.

Parameters
[in]rRay to compute the squared distance to.
[out]p1First point at the minimum distance (on the current box).
[out]p2Second point at the minimum distance (on the ray).
[in]tolTolerance to use for the distance computation.
Returns
The squared distance between the ray and the box.
Note
The squared distance is positive if the ray and the box do not intersect, zero otherwise.

◆ squared_interior_distance() [6/6]

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::squared_interior_distance ( Ray< Real, N > const & r,
Real tol = DUMMY_TOL ) const
inline

Compute the squared interior (or minimum) distance between the current box a given ray.

Parameters
[in]rRay to compute the squared distance to.
[in]tolTolerance to use for the distance computation.
Returns
The squared distance between the ray and the box.
Note
The squared distance is positive if the ray and the box do not intersect, zero otherwise.

◆ surface()

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::surface ( ) const
inline

Compute the surface area of the box.

Returns
Sum of areas of all faces.

◆ transform()

template<typename Real, Integer N>
template<typename Transform>
Box & AABBtree::Box< Real, N >::transform ( Transform const & t)
inline

Transform this box in-place.

Parameters
[in]tTransformation to apply.
Returns
Reference to this box after transformation.
Template Parameters
TransformType of the transformation.
Note
The resulting box may be larger than the original due to axis-alignment.

◆ transformed()

template<typename Real, Integer N>
template<typename Transform>
Box AABBtree::Box< Real, N >::transformed ( Transform const & t) const
inline

Create a transformed copy of this box.

Parameters
[in]tTransformation to apply.
Returns
New transformed box.
Template Parameters
TransformType of the transformation.
Note
The resulting box may be larger than the original due to axis-alignment.

◆ translate()

template<typename Real, Integer N>
Box & AABBtree::Box< Real, N >::translate ( Vector const & t)
inline

Translate the box by a given vector.

Parameters
[in]tTranslation vector.
Returns
Reference to this box after translation.

◆ translated()

template<typename Real, Integer N>
Box AABBtree::Box< Real, N >::translated ( Vector const & t) const
inline

Create a translated copy of this box.

Parameters
[in]tTranslation vector.
Returns
New translated box.

◆ volume()

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::volume ( ) const
inline

Compute the volume of the box.

Returns
Product of sizes in all dimensions.

◆ which_side()

template<typename Real, Integer N>
Side AABBtree::Box< Real, N >::which_side ( Real const x,
Real const tol,
Integer const dim ) const
inline

Classify a coordinate relative to the box in a specific dimension.

Parameters
[in]xCoordinate to classify.
[in]tolTolerance for classification.
[in]dimDimension to consider.
Returns
Side::LEFT if max[dim] < x+tol, Side::RIGHT if x-tol < min[dim], Side::INSIDE otherwise.

Member Data Documentation

◆ DUMMY_TOL

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::DUMMY_TOL {EPS*static_cast<Real>(100.0)}
staticconstexprprivate

Default tolerance for the scalar type

◆ EPS

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::EPS {std::numeric_limits<Real>::epsilon()}
staticconstexprprivate

Machine epsilon for the scalar type.

◆ INF

template<typename Real, Integer N>
Real AABBtree::Box< Real, N >::INF {std::numeric_limits<Real>::infinity()}
staticconstexprprivate

Infinity value for the scalar type.

◆ m_max

template<typename Real, Integer N>
Point AABBtree::Box< Real, N >::m_max
private

Maximal corner of the box (upper bounds in all dimensions).

◆ m_min

template<typename Real, Integer N>
Point AABBtree::Box< Real, N >::m_min
private

Minimal corner of the box (lower bounds in all dimensions).


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