Skip to main content

BoundBox

The BoundBox type defines an axis-aligned bounding box (AABB) for 3D space, providing efficient spatial containment, expansion, and intersection logic. It supports initialization from points, spheres, and other bounding boxes, and offers utilities for validation, distance computation, ray intersection, and spatial queries. The implementation prioritizes performance, precision, and flexibility with support for custom vector types.

#include <geometry/TellusimBounds.h>

BoundBoxf

Represents a BoundBox using 32-bit floating-point precision.

BoundBoxd

Represents a BoundBox using 64-bit floating-point precision.

Variables

TypeNameDescription
Vector3minMinimum extent.
Vector3maxMaximum extent.
Vector3points[2]Array access.

Constructors

BoundBox()
BoundBox(const BoundBox &bb)
BoundBox(const Vector3 &bb_min, const Vector3 &bb_max)
BoundBox(const Vector3 &bs_center, Type bs_radius)
BoundBox(const BoundBox &bb, const BoundSphere &bs)
explicit BoundBox(const BoundSphere &bs)
explicit BoundBox(const BoundBox<CType, CVector> &bb)
explicit BoundBox(const BoundSphere<CType, CVector> &bs)
BoundBox(const Vector3 *points, uint32_t num_points)

Methods

Clear bound box.

void clear()

Check bound box.

bool isValid() const
operator bool() const

Set bound box.

void set(const Vector3 &bb_min, const Vector3 &bb_max)
void set(const BoundBox &bb)

Set bound sphere.

void set(const Vector3 &bs_center, Type bs_radius)
void set(const BoundSphere &bs)

Set minimal bound box.

void set(const Vector3 &bb_min, const Vector3 &bb_max, const Vector3 &bs_center, Type bs_radius)
void set(const BoundBox &bb, const BoundSphere &bs)

Set bound box.

void set(const Vector3 *points, uint32_t num_points)

Expand by point.

void expand(const Vector3 &point)

Expand by bound box.

void expand(const Vector3 &bb_min, const Vector3 &bb_max)
void expand(const BoundBox &bb)

Expand by bound sphere.

void expand(const Vector3 &bs_center, Type bs_radius)
void expand(const BoundSphere &bs)

Expand by minimal bounds.

void expand(const Vector3 &bb_min, const Vector3 &bb_max, const Vector3 &bs_center, Type bs_radius)
void expand(const BoundBox &bb, const BoundSphere &bs)

Shrink by bound box.

void shrink(const Vector3 &bb_min, const Vector3 &bb_max)
void shrink(const BoundBox &bb)

Shrink by bound sphere.

void shrink(const Vector3 &bs_center, Type bs_radius)
void shrink(const BoundSphere &bs)

Inside point.

bool inside(const Vector3 &point) const

Inside bound box.

bool inside(const Vector3 &bb_min, const Vector3 &bb_max) const
bool inside(const BoundBox &bb) const

Inside bound sphere.

bool inside(const Vector3 &bs_center, Type bs_radius) const
bool inside(const BoundSphere &bs) const

Signed distance to the bound box.

Type distance(const Vector3 &point) const

Bound box ray intersection.

Vector2 trace(const Vector3 &point, const Vector3 &idirection) const

To bound sphere.

Vector3 getCenter() const
Type getRadius() const

Bound box parameters.

Vector3 getSize() const
const Vector3 &getMin() const
const Vector3 &getMax() const
const Vector3 *getPoints() const
Type getVolume(Type threshold = 1e-8f) const

Operators

Matrix to bound box multiplication.

BoundBox operator*(const Matrix4x3 &m, const BoundBox &bb)
BoundBox operator*(const Matrix4x4 &m, const BoundBox &bb)

Comparison operators.

bool operator==(const BoundBox &bb0, const BoundBox &bb1)
bool operator!=(const BoundBox &bb0, const BoundBox &bb1)