pub struct Box3 {
pub origin: Point3,
pub x: Vec3,
pub y: Vec3,
pub z: Vec3,
}Expand description
An oriented box: the generalization of a rectangle to three dimensions.
Distinct from Aabb, which is axis-aligned and exists for broad-phase
rejection. This one carries its own orientation, so it can bound a rotated
object tightly where an axis-aligned box would not.
The three edge vectors are not required to be mutually perpendicular, for
the same reason Rectangle3 does not require it: a dirty import stays
representable and inspectable.
Fields§
§origin: Point3Corner the edge vectors start from.
x: Vec3First edge vector, from origin.
y: Vec3Second edge vector, from origin.
z: Vec3Third edge vector, from origin.
Implementations§
Source§impl Box3
impl Box3
Sourcepub const fn new(origin: Point3, x: Vec3, y: Vec3, z: Vec3) -> Self
pub const fn new(origin: Point3, x: Vec3, y: Vec3, z: Vec3) -> Self
Construct from a corner and three edge vectors.
Sourcepub fn corners(&self) -> [Point3; 8]
pub fn corners(&self) -> [Point3; 8]
The eight corners.
Ordered so bit 0 selects x, bit 1 selects y, and bit 2 selects z:
index 0 is origin and index 7 is the far corner. That ordering lets a
caller index a corner by axis mask instead of memorising a winding.
Sourcepub fn signed_volume(&self) -> Scalar
pub fn signed_volume(&self) -> Scalar
Signed volume. Negative when the edge vectors are left-handed.
Signed rather than absolute so a caller can detect an inverted frame, which is a common symptom of a mirrored or badly converted import.