Skip to content

Box3

Axis-aligned bounding box defined by minimum and maximum corners.

Box3 represents a 3D region bounded by two corners: min and max. It is used for spatial queries, culling tests, intersection checks, and computing bounding volumes. All operations assume the box is axis-aligned in the current coordinate space.

Construction

Constructors


Box3() constexpr

Constructs a box from minimum and maximum corners.

cpp
Box3::Box3(const Vector3& v_min, const Vector3& v_max);
ParameterDescription
v_minMinimum point.
v_maxMaximum point.

Properties

Maximum corner of the box.

cpp
Vector3 max {std::numeric_limits<float>::lowest()};

Minimum corner of the box.

cpp
Vector3 min {std::numeric_limits<float>::max()};

Functions

ApplyTransform() void

Applies a transform to the box.

Computes the axis-aligned bounding box that encloses the transformed eight corners of the original box.

cpp
void Box3::ApplyTransform(const Matrix4& transform);
ParameterDescription
transformTransformation matrix to apply.

Center() Vector3

Returns the geometric center of the box.

cpp
Vector3 Box3::Center() const;

ExpandWithPoint() void

Expands the box to include a point.

If the point lies outside the current bounds, min and max are adjusted to enclose it.

cpp
void Box3::ExpandWithPoint(const Vector3& point);
ParameterDescription
pointPoint to include.

IsEmpty() bool

Checks whether the box is empty.

A box is empty when any component of min exceeds the corresponding component of max, meaning it encloses no volume.

cpp
bool Box3::IsEmpty() const;

Reset() void

Resets the box to an empty state.

After calling this, the next expanded point will define the new bounds.

cpp
void Box3::Reset();

Translate() void

Translates the box.

Adds the translation vector to both min and max.

cpp
void Box3::Translate(const Vector3& translation);
ParameterDescription
translationOffset to apply.

Union() void

Expands this box to contain another box.

cpp
void Box3::Union(const Box3& other);
ParameterDescription
otherBox to merge.

Released under the MIT License.