pub struct BoundingBox3D {
pub min_x: f64,
pub min_y: f64,
pub min_z: f64,
pub max_x: f64,
pub max_y: f64,
pub max_z: f64,
}Expand description
An axis-aligned 3-D bounding box.
Invariant: min_x ≤ max_x, min_y ≤ max_y, min_z ≤ max_z.
This invariant is enforced by BoundingBox3D::new.
Fields§
§min_x: f64Minimum X coordinate.
min_y: f64Minimum Y coordinate.
min_z: f64Minimum Z coordinate.
max_x: f64Maximum X coordinate.
max_y: f64Maximum Y coordinate.
max_z: f64Maximum Z coordinate.
Implementations§
Source§impl BoundingBox3D
impl BoundingBox3D
Sourcepub fn new(
min_x: f64,
min_y: f64,
min_z: f64,
max_x: f64,
max_y: f64,
max_z: f64,
) -> Option<Self>
pub fn new( min_x: f64, min_y: f64, min_z: f64, max_x: f64, max_y: f64, max_z: f64, ) -> Option<Self>
Construct a new bounding box.
Returns None if any min > max invariant is violated.
Sourcepub fn from_points(points: &[Point3D]) -> Option<Self>
pub fn from_points(points: &[Point3D]) -> Option<Self>
Build the tightest bounding box that contains every point in points.
Returns None when points is empty.
Sourcepub fn contains(&self, p: &Point3D) -> bool
pub fn contains(&self, p: &Point3D) -> bool
Return true when p is strictly inside or on the boundary.
Sourcepub fn intersects_2d(&self, other: &BoundingBox3D) -> bool
pub fn intersects_2d(&self, other: &BoundingBox3D) -> bool
Return true when the XY footprints of self and other overlap (or
touch).
Sourcepub fn intersects_3d(&self, other: &BoundingBox3D) -> bool
pub fn intersects_3d(&self, other: &BoundingBox3D) -> bool
Return true when self and other share any volume (or face).
Sourcepub fn expand_by(&self, delta: f64) -> Self
pub fn expand_by(&self, delta: f64) -> Self
Return a box expanded symmetrically in every direction by delta.
If delta is negative the box may collapse; the result will still
satisfy the min ≤ max invariant because f64 arithmetic naturally
produces equal values when expansion < 0 produces min > max (the
caller should validate the result if that matters).
Sourcepub fn split_octants(&self) -> [BoundingBox3D; 8]
pub fn split_octants(&self) -> [BoundingBox3D; 8]
Subdivide the box into eight equal octant children.
Children are ordered by (x_high, y_high, z_high) bits:
index 0 = (lo, lo, lo), index 7 = (hi, hi, hi).
Trait Implementations§
Source§impl Clone for BoundingBox3D
impl Clone for BoundingBox3D
Source§fn clone(&self) -> BoundingBox3D
fn clone(&self) -> BoundingBox3D
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more