API Reference · Geometry

BoundingBox

Namespace: Ava3D

public readonly record struct BoundingBox

An axis-aligned box. Used for camera framing and to reject picks cheaply.

Constructors

MemberDescription
BoundingBox(Vector3 Min, Vector3 Max)

An axis-aligned box. Used for camera framing and to reject picks cheaply.

Min

The corner with the smallest coordinate on every axis.

Max

The corner with the largest coordinate on every axis.

Properties

MemberDescription
Vector3 Center { get; }

The midpoint, or the origin when the box is empty.

static BoundingBox Empty { get; }

A box that contains nothing, and absorbs any point or box unioned into it.

bool IsEmpty { get; }

Whether the box contains nothing. An empty box has a min greater than its max.

Vector3 Max { get; set; }

The corner with the largest coordinate on every axis.

Vector3 Min { get; set; }

The corner with the smallest coordinate on every axis.

float Radius { get; }

Radius of the sphere that contains the box. Never zero, so it is safe to divide by.

Vector3 Size { get; }

Extent along each axis, or zero when the box is empty.

Methods

MemberDescription
Nullable<float> Intersect(Vector3 origin, Vector3 direction)

Distance along the ray at which it enters the box, or null if it misses.

BoundingBox Transform(in Matrix4x4 m)

The box that contains this one after m is applied. All eight corners are transformed, because a rotated box's extent is not the transform of its extent.

BoundingBox Union(in BoundingBox other)

The smallest box containing both. Unioning with an empty box returns the other unchanged.

BoundingBox Union(Vector3 point)

The smallest box containing this one and point.

See also