|
|
template<class T > |
| bool | celeritas::is_infinite (BoundingBox< T > const &bbox) |
| | Check if a bounding box spans (-inf, inf) in every direction.
|
| |
| template<class T > |
| bool | celeritas::is_finite (BoundingBox< T > const &bbox) |
| | Check if a bounding box has no infinities.
|
| |
| template<class T > |
| bool | celeritas::is_degenerate (BoundingBox< T > const &bbox) |
| | Check if a bounding box has zero length in any direction.
|
| |
|
template<class T > |
| bool | celeritas::is_half_inf (BoundingBox< T > const &bbox) |
| | Whether any axis has an infinity on one bound but not the other.
|
| |
| template<class T > |
| Array< T, 3 > | celeritas::calc_center (BoundingBox< T > const &bbox) |
| | Calculate the center of a bounding box.
|
| |
| template<class T > |
| Array< T, 3 > | celeritas::calc_half_widths (BoundingBox< T > const &bbox) |
| | Calculate the half widths of the bounding box.
|
| |
| template<class T > |
| T | celeritas::calc_surface_area (BoundingBox< T > const &bbox) |
| | Calculate the surface area of a bounding box.
|
| |
| template<class T > |
| T | celeritas::calc_volume (BoundingBox< T > const &bbox) |
| | Calculate the volume of a bounding box.
|
| |
|
template<class T > |
| constexpr BoundingBox< T > | celeritas::calc_union (BoundingBox< T > const &a, BoundingBox< T > const &b) |
| | Calculate the smallest bounding box enclosing two bounding boxes.
|
| |
| template<class T > |
| constexpr BoundingBox< T > | celeritas::calc_intersection (BoundingBox< T > const &a, BoundingBox< T > const &b) |
| | Calculate the intersection of two bounding boxes.
|
| |
| template<class T > |
| T | celeritas::calc_overlap_fraction (BoundingBox< T > const &a, BoundingBox< T > const &b) |
| | Calculate the overlap fraction.
|
| |
| template<class T > |
| bool | celeritas::encloses (BoundingBox< T > const &big, BoundingBox< T > const &small) |
| | Check if all points inside the small bbox are in the big bbox.
|
| |
| template<class T > |
| bool | celeritas::intersects_segment (BoundingBox< T > const &bbox, Array< T, 3 > const &pos, Array< T, 3 > const &dir, T distance) |
| | Check if a line segment may intersect a bounding box.
|
| |
|
BBox | celeritas::calc_transform (Translation const &tr, BBox const &a) |
| | Calculate the bounding box of a translated box.
|
| |
| BBox | celeritas::calc_transform (Transformation const &tr, BBox const &a) |
| | Calculate the axis-aligned bounding box of a transformed box.
|
| |
Utilities for bounding boxes.
Calculate the axis-aligned bounding box of a transformed box.
Transforming a box usually results in an oriented bounding box, but sometimes that OBB is also an AABB. This function implicitly creates the transformed bounding box and creates an AABB that encompasses that box.
The result returns an exactly transformed bounding box for axis-aligned rotations. To achieve exactness for semi-infinite bounding boxes, this method has a custom implementation of GEMV for applying exact rotations if the matrix representation simply switches vector entries or flips their sign. Without the complication, floating point arithmetic results in NaN from multiplying zeroes (in the matrix) by the infinite values.
Check if a line segment may intersect a bounding box.
The line segment is defined from pos in direction dir with length distance. If the position is already inside the bounding box, the result is always true.
This uses a separating-axis test (see ericson-collision-2004 ). It translates the coordinate system to the center of the bbox and tests six axes (see Fig. 5.23, Table 5.1 in reference):
- the AABB face normals, and
- the cross products between the direction vector and face normals .
Modifications have been made from the original algorithm for robustness and GPU performance.
- Manual unrolling and unconditional evaluation of the off-axis tests lead to a 10% speedup in the along-step kernel and enable automatic vectorization when compiled with clang for aarch64.
- A relative rather than absolute tolerance is used to support large distances.
- Instead of using the midpoint of the line segment \( m \equiv x + d/2 - c \), we operate on the translated midpoint of the bbox \( c' \equiv c - x \) . This prevents the distance from being squared before subtraction in the cross-product directions, which can lead to machine-dependent catastrophic floating point errors for distances on the order of \( 1/\epsilon_\mathrm{machine} \) ).
- Warning
- Large segment lengths are allowed to support degenerate cases, but they may result in false positives (and result in slowing down a BVH search).