NavMap
Loading...
Searching...
No Matches
AABB Struct Reference

Axis-aligned bounding box. More...

#include <Geometry.hpp>

Collaboration diagram for AABB:

Public Member Functions

bool contains_xy (const Vec3 &p, float z_eps) const
 2D containment test on XY with tolerance in Z.
 
bool contains_xy_only (const Vec3 &p) const
 2D containment test on XY only (no Z check).
 
void expand (const AABB &b)
 Expand the box to include another box b (component-wise union).
 
void expand (const Vec3 &p)
 Expand the box to include a point p.
 
bool intersects_ray (const Vec3 &o, const Vec3 &d, float tmax=1e30f) const
 Robust ray-box intersection (slabs method).
 
int longest_axis () const
 Return the index of the longest axis (0=x, 1=y, 2=z).
 

Public Attributes

Vec3 max
 Maximum corner (x_max, y_max, z_max).
 
Vec3 min
 Minimum corner (x_min, y_min, z_min).
 

Detailed Description

Axis-aligned bounding box.

Stores component-wise minima/maxima and provides helpers for:

  • Union/expansion with points or other AABBs.
  • Longest axis query (for BVH splitting).
  • Robust ray-box intersection (slabs method).
  • XY containment with and without Z tolerance.

Member Function Documentation

◆ contains_xy()

bool contains_xy ( const Vec3 & p,
float z_eps ) const

2D containment test on XY with tolerance in Z.

Checks if point p lies inside the XY rectangle and within a vertical band around [min.z, max.z] expanded by z_eps.

Parameters
pQuery point.
z_epsExtra vertical half-thickness tolerance.
Returns
True if inside XY and |z - [min.z,max.z]| <= z_eps.

◆ contains_xy_only()

bool contains_xy_only ( const Vec3 & p) const

2D containment test on XY only (no Z check).

Parameters
pQuery point.
Returns
True if inside XY rectangle [min,max].

◆ expand() [1/2]

void expand ( const AABB & b)

Expand the box to include another box b (component-wise union).

Parameters
bOther AABB to merge.

◆ expand() [2/2]

void expand ( const Vec3 & p)

Expand the box to include a point p.

Parameters
pPoint to merge into this AABB.

◆ intersects_ray()

bool intersects_ray ( const Vec3 & o,
const Vec3 & d,
float tmax = 1e30f ) const

Robust ray-box intersection (slabs method).

Intersects ray (o + t * d) against the box. Handles zero components in direction d by checking slab containment on that axis.

Parameters
oRay origin.
dRay direction.
tmaxUpper bound for t interval (can be +inf).
Returns
True if the ray intersects the box with some t in [0, tmax].

◆ longest_axis()

int longest_axis ( ) const

Return the index of the longest axis (0=x, 1=y, 2=z).

Returns
Axis index with the largest extent.

Member Data Documentation

◆ max

Vec3 max
Initial value:
{-std::numeric_limits<float>::infinity(),
-std::numeric_limits<float>::infinity(),
-std::numeric_limits<float>::infinity()}

Maximum corner (x_max, y_max, z_max).

Initialized to -inf.

◆ min

Vec3 min
Initial value:
{std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity()}

Minimum corner (x_min, y_min, z_min).

Initialized to +inf.


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