Mundy: Multibody Nonlocal Dynamics Version of the Day
Loading...
Searching...
No Matches
OBB.hpp File Reference

Oriented Bounding Box (OBB) primitive. More...

Classes

class  mundy::OBB< Scalar, PointType, QuaternionType, HalfExtentsType >
 Oriented Bounding Box: a center, a unit-quaternion orientation, and per-axis half-extents. More...
struct  mundy::is_obb< T >

Namespaces

namespace  mundy

Concepts

concept  mundy::ValidOBBType

Functions

Approximate equality
template<ValidOBBType T1, ValidOBBType T2>
constexpr bool mundy::is_close (const T1 &a, const T2 &b, typename T1::value_type tol=get_comparison_tolerance< typename T1::value_type, typename T2::value_type >())
template<ValidOBBType T1, ValidOBBType T2>
constexpr bool mundy::is_approx_close (const T1 &a, const T2 &b, typename T1::value_type tol=get_relaxed_comparison_tolerance< typename T1::value_type, typename T2::value_type >())
Intersection test
template<ValidOBBType OBBType1, ValidOBBType OBBType2>
constexpr bool mundy::intersects (const OBBType1 &a, const OBBType2 &b)
 Test whether two OBBs overlap using the Separating Axis Theorem (SAT).
Stream output
template<ValidOBBType T>
std::ostream & mundy::operator<< (std::ostream &os, const T &obb)
Point visitation
template<ValidOBBType T, typename Functor>
void mundy::for_each_point (const T &obb, Functor &&f)
template<ValidOBBType T, typename Functor>
void mundy::for_each_point_mutable (T &obb, Functor &&f)

Variables

template<typename T>
constexpr bool mundy::is_obb_v = is_obb<T>::value

Detailed Description

Storage

An OBB is stored as three independent quantities:

  • center — a Point<Scalar> giving the box centroid in world space.
  • orientation — a unit Quaternion<Scalar> representing the rotation that maps local box axes to world space. The local x/y/z axes are the first/second/third columns of the rotation matrix derived from this quaternion.
  • half_extents — a Vector3<Scalar> giving the half-lengths of the box along each local axis (all non-negative).

Why quaternion orientation?

Performance tests show that computing the relative rotation matrix R = mat(conj(q_A)*q_B) needed for an OBB–OBB SAT test costs essentially the same as R = Q_A^T Q_B when orientations are stored as rotation matrices (~6 ns on a Cascade Lake core), while the quaternion representation reduces the per-OBB memory footprint from 15 scalars to 10 scalars. On memory-bandwidth-bound GPU workloads — the primary use case for MundySearch narrow-phase excluders — the smaller footprint is preferred.