pub struct Obb3 {
pub center: Point3,
pub axes: [Vec3; 3],
pub half_extents: [f64; 3],
}Expand description
A 3D oriented bounding box.
Stores a center, three orthonormal axes, and half-extents along each axis.
Fields§
§center: Point3Center of the box.
axes: [Vec3; 3]Three orthonormal axes (columns of the rotation matrix).
half_extents: [f64; 3]Half-extents along each axis.
Implementations§
Source§impl Obb3
impl Obb3
Sourcepub fn from_points(points: impl IntoIterator<Item = Point3>) -> Self
pub fn from_points(points: impl IntoIterator<Item = Point3>) -> Self
Build an OBB from a point set using PCA (principal component analysis).
Computes the covariance matrix of the points, extracts eigenvectors as the OBB axes, then projects all points to find the extents.
Uses canonical axes for degenerate point sets (collinear or coincident).
§Panics
Panics if the iterator yields fewer than 1 point.
Sourcepub fn from_points_slice(pts: &[Point3]) -> Self
pub fn from_points_slice(pts: &[Point3]) -> Self
Build an OBB from a slice of points using PCA (principal component analysis).
Same as from_points but avoids an allocation when the
caller already has a slice.
§Panics
Panics if the slice is empty.
Sourcepub fn from_points_with_normal(
points: impl IntoIterator<Item = Point3>,
normal: Vec3,
) -> Self
pub fn from_points_with_normal( points: impl IntoIterator<Item = Point3>, normal: Vec3, ) -> Self
Build an OBB with a known primary axis (e.g. face normal for planar faces).
Uses the given normal as one axis and PCA in the remaining plane for the other two. This gives near-zero thickness for planar faces.
§Panics
Panics if the iterator yields fewer than 1 point.
Sourcepub fn from_slice_with_normal(pts: &[Point3], normal: Vec3) -> Self
pub fn from_slice_with_normal(pts: &[Point3], normal: Vec3) -> Self
Build an OBB with a known primary axis from a slice of points.
Same as from_points_with_normal but avoids
an allocation when the caller already has a slice.
§Panics
Panics if the slice is empty.
Sourcepub fn intersects(&self, other: &Self) -> bool
pub fn intersects(&self, other: &Self) -> bool
Test whether two OBBs intersect using the Separating Axis Theorem.
Tests 15 potential separating axes: 3 from each OBB + 9 cross products.
Returns true if the OBBs overlap (no separating axis found).