![]() |
AABBtree
0.0.0
A C++ non-recursive ND AABB tree
|
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) | |
Box & | operator= (Box const &b)=default |
template<typename NewReal> | |
Box< NewReal, N > | cast () const |
Point const & | min () const |
Point & | min () |
Point const & | max () const |
Point & | max () |
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 |
Box & | translate (Vector const &t) |
Box | translated (Vector const &t) const |
template<typename Transform> | |
Box | transformed (Transform const &t) const |
template<typename Transform> | |
Box & | transform (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> | |
Box & | extend (Point const &p) |
Box & | extend (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)} |
This class represents an axis-aligned bounding box (AABB) defined by two opposite corners:
The Box class provides various geometric operations including:
Real | Floating-point scalar type (must be float or double). |
N | Dimension of the ambient space. |
|
private |
|
private |
|
private |
|
private |
|
strong |
|
default |
Class destructor for the axis-aligned box.
|
inline |
Default constructor creating an empty box whether the minimal and maximal corners are set to the maximum and minimum representable values, respectively.
|
inline |
Copy constructor for a axis-aligned box given another box.
[in] | b | Box to copy. |
|
inline |
Class constructor for a axis-aligned box given the minimal and maximal corners.
[in] | t_min | Minimal corner of the box. |
[in] | t_max | Maximal corner of the box. |
|
inline |
Class constructor for a axis-aligned box containing a single point.
[in] | p | Point to be contained in the box. |
|
inline |
Class constructor for the 1D axis-aligned bounding box.
[in] | x_min | Minimal \( x \)-axis corner of the box. |
[in] | x_max | Maximal \( x \)-axis corner of the box. |
T | Type of the scalar coefficients. |
|
inline |
Class constructor for the 2D axis-aligned bounding box.
[in] | x_min | Minimal \( x \)-axis corner of the box. |
[in] | y_min | Minimal \( y \)-axis corner of the box. |
[in] | x_max | Maximal \( x \)-axis corner of the box. |
[in] | y_max | Maximal \( y \)-axis corner of the box. |
T | Type of the scalar coefficients. |
|
inline |
Class constructor for the 3D axis-aligned bounding box.
[in] | x_min | Minimal \( x \)-axis corner of the box. |
[in] | y_min | Minimal \( y \)-axis corner of the box. |
[in] | z_min | Minimal \( z \)-axis corner of the box. |
[in] | x_max | Maximal \( x \)-axis corner of the box. |
[in] | y_max | Maximal \( y \)-axis corner of the box. |
[in] | z_max | Maximal \( z \)-axis corner of the box. |
T | Type of the scalar coefficients. |
|
inlineexplicit |
Copy constructor for a axis-aligned box given another box with a different scalar type.
[in] | b | Box to copy. |
OtherReal | Type of the scalar coefficients of the box to copy. |
|
inline |
Compute the barycenter of the box.
|
inline |
Compute the barycenter coordinate along a specific dimension.
[in] | i | Dimension index. |
|
inline |
Cast the current object to a new scalar type.
NewReal | the new scalar type. |
|
inline |
Check if this box completely contains another box.
[in] | b | Box to check. |
|
inline |
Check if a point is inside the box.
[in] | p | Point to check. |
|
inline |
Compute the diagonal vector of the box.
diagonal()
.norm() .
|
inline |
Extend this box to contain another box.
[in] | b | Box to include. |
*this
.
|
inline |
Extend this box to contain a point.
[in] | p | Point to include. |
|
inline |
Compute the exterior (or maximum) distance between the current box a given box.
[in] | b | Box to compute the distance to. |
|
inline |
Compute the exterior (or maximum) distance between the current box a given box, and return two points at the maximum distance.
[in] | b | Box to compute the distance to. |
[out] | p1 | First point at the maximum distance. |
[out] | p2 | Second point at the maximum distance. |
|
inline |
Compute the exterior (or maximum) distance between the current box a given point.
[in] | p | Point to compute the distance to. |
|
inline |
Compute the exterior (or maximum) distance between the current box a given point, returning a point at the given distance.
[in] | p | Point to compute the distance to. |
[out] | f | Farthest point to the box. |
|
inline |
Compute the exterior (or maximum) distance between the current box a given ray, and return two points at the maximum distance.
[in] | r | Ray to compute the distance to. |
[out] | p1 | First point at the maximum distance (on the current box). |
[out] | p2 | Second point at the maximum distance (on the ray). |
[in] | tol | Tolerance to use for the distance computation. |
|
inline |
Compute the exterior (or maximum) distance between the current box a given ray.
[in] | r | Ray to compute the distance to. |
[in] | tol | Tolerance to use for the distance computation. |
|
inline |
Compute the interior (or minimum) distance between the current box a given box.
[in] | b | Box to compute the distance to. |
|
inline |
Compute the interior (or minimum) distance between the current box a given box, returning two points at the minimum distance.
[in] | b | Box to compute the distance to. |
[out] | p1 | First point at the minimum distance. |
[out] | p2 | Second point at the minimum distance. |
|
inline |
Compute the interior (or minimum) distance between the current box a given point.
[in] | p | Point to compute the distance to. |
|
inline |
Compute the interior (or minimum) distance between the current box a given point, returning a point at the given distance.
[in] | p | Point to compute the distance to. |
[out] | c | Closest point to the box. |
|
inline |
Compute the interior (or minimum) distance between the current box a given ray, returning two points at the minimum distance.
[in] | r | Ray to compute the distance to. |
[out] | p1 | First point at the minimum distance (on the current box). |
[out] | p2 | Second point at the minimum distance (on the ray). |
[in] | tol | Tolerance to use for the distance computation. |
|
inline |
Compute the interior (or minimum) distance between the current box a given ray.
[in] | r | Ray to compute the distance to. |
[in] | tol | Tolerance to use for the distance computation. |
|
inline |
Compute the intersection of this box with another box.
[in] | b_in | Box to intersect with. |
[out] | b_out | Resulting intersection box. |
|
inline |
Check if the current box intersects a given ray.
[in] | r | Ray to check. |
[out] | c | Closest intersection point. |
[out] | f | Farthest intersection point. |
[in] | tol | Tolerance to use for the intersection. |
|
inline |
Check if this box intersects with another box.
[in] | b | Box to check for intersection. |
|
inline |
Check if a point intersects the box.
[in] | p | Point to check. |
contains()
for points.
|
inline |
Check if the current box intersects a given ray.
[in] | r | Ray to check. |
[in] | tol | Tolerance to use for the intersection. |
|
inline |
Check if this box is approximately equal to another box.
[in] | b | Box to compare with. |
[in] | tol | Tolerance for the comparison. |
|
inline |
Check if the current box is degenrate, i.e., it has zero volume.
[in] | tol | Tolerance to use for the comparison. |
|
inline |
Check if the box is empty, i.e., the minimal corner is greater than the maximal corner in any dimension.
|
inline |
Find the longest axis of the box.
|
inline |
Find the longest axis and compute its length and midpoint.
[out] | max_length | Length of the longest axis. |
[out] | mid_point | Midpoint of the longest axis. |
|
inline |
Get a non const reference to the maximal corner.
|
inline |
Get the maximal corner.
|
inline |
Compute the union of this box with another box.
[in] | b | Box to merge with. |
|
inline |
Get a non const reference to the minimal corner.
|
inline |
Get the minimal corner.
|
default |
Assignment perator for a axis-aligned box given another box.
[in] | b | Box to copy. |
|
inline |
Print the box info to an output stream.
[in] | os | Output stream to print the box info to. |
|
inline |
Reorder the corners of the box such that the minimal corner is less than the maximal corner.
|
inline |
Set the box to be degenerate (containing a single point).
[in] | p | Point to set the box to. |
|
inline |
Set the box to be empty.
|
inline |
|
inline |
Compute the squared exterior (or maximum) distance between the current box a given box.
[in] | b | Box to compute the squared distance to. |
|
inline |
Compute the squared exterior (or maximum) distance between the current box a given box, returning two points at the maximum distance.
[in] | b | Box to compute the squared distance to. |
[out] | p1 | First point at the maximum distance. |
[out] | p2 | Second point at the maximum distance. |
|
inline |
Compute the squared exterior (or maximum) distance between the current box a given point.
[in] | p | Point to compute the squared distance to. |
|
inline |
Compute the squared exterior (or maximum) distance between the current box a given point, returning a point at the given distance.
[in] | p | Point to compute the squared distance to. |
[out] | f | Farthest point to the box. |
|
inline |
Compute the squared exterior (or maximum) distance between the current box a given ray, returning two points at the maximum distance.
[in] | r | Ray to compute the squared distance to. |
[out] | p1 | First point at the maximum distance (on the current box). |
[out] | p2 | Second point at the maximum distance (on the ray). |
[in] | tol | Tolerance to use for the distance computation. |
|
inline |
Compute the squared exterior (or maximum) distance between the current box a given ray.
[in] | r | Ray to compute the squared distance to. |
[in] | tol | Tolerance to use for the distance computation. |
|
inline |
Compute the squared interior (or minimum) distance between the current box a given box.
[in] | b | Box to compute the squared distance to. |
|
inline |
Compute the squared interior (or minimum) distance between the current box a given box, returning two points at the minimum distance.
[in] | b | Box to compute the squared distance to. |
[out] | p1 | First point at the minimum distance. |
[out] | p2 | Second point at the minimum distance. |
|
inline |
Compute the squared interior (or minimum) distance between the current box a given point.
[in] | p | Point to compute the squared distance to. |
|
inline |
Compute the squared interior (or minimum) distance between the current box a given point, returning a point at the given distance.
[in] | p | Point to compute the squared distance to. |
[out] | c | Closest point to the box. |
|
inline |
Compute the squared interior (or minimum) distance between the current box a given ray, returning two points at the minimum distance.
[in] | r | Ray to compute the squared distance to. |
[out] | p1 | First point at the minimum distance (on the current box). |
[out] | p2 | Second point at the minimum distance (on the ray). |
[in] | tol | Tolerance to use for the distance computation. |
|
inline |
Compute the squared interior (or minimum) distance between the current box a given ray.
[in] | r | Ray to compute the squared distance to. |
[in] | tol | Tolerance to use for the distance computation. |
|
inline |
Compute the surface area of the box.
|
inline |
Transform this box in-place.
[in] | t | Transformation to apply. |
Transform | Type of the transformation. |
|
inline |
Create a transformed copy of this box.
[in] | t | Transformation to apply. |
Transform | Type of the transformation. |
|
inline |
Translate the box by a given vector.
[in] | t | Translation vector. |
|
inline |
Create a translated copy of this box.
[in] | t | Translation vector. |
|
inline |
Compute the volume of the box.
|
inline |
Classify a coordinate relative to the box in a specific dimension.
[in] | x | Coordinate to classify. |
[in] | tol | Tolerance for classification. |
[in] | dim | Dimension to consider. |
|
staticconstexprprivate |
Default tolerance for the scalar type
|
staticconstexprprivate |
Machine epsilon for the scalar type.
|
staticconstexprprivate |
Infinity value for the scalar type.
|
private |
Maximal corner of the box (upper bounds in all dimensions).
|
private |
Minimal corner of the box (lower bounds in all dimensions).