pub struct Aabb {
pub min: [f64; 3],
pub max: [f64; 3],
}Expand description
The axis-aligned box around a set of points: min ≤ max on every axis,
both finite. A box is never empty; an empty point set has no box.
use arris_math::Aabb;
let b = Aabb::of_points(&[[0.0, 0.0, 0.0], [2.0, -1.0, 3.0]]).unwrap();
assert_eq!(b.min, [0.0, -1.0, 0.0]);
assert_eq!(b.max, [2.0, 0.0, 3.0]);
assert_eq!(b.extent(), [2.0, 1.0, 3.0]);
assert_eq!(b.center(), [1.0, -0.5, 1.5]);Fields§
§min: [f64; 3]The smallest coordinate on each axis.
max: [f64; 3]The largest coordinate on each axis.
Implementations§
Source§impl Aabb
impl Aabb
Sourcepub fn of_points<'a>(
points: impl IntoIterator<Item = &'a [f64; 3]>,
) -> Option<Aabb>
pub fn of_points<'a>( points: impl IntoIterator<Item = &'a [f64; 3]>, ) -> Option<Aabb>
The box around points, or None for no points.
Sourcepub fn of_point(p: Point3) -> Aabb
pub fn of_point(p: Point3) -> Aabb
The box holding one point, of zero extent.
use arris_math::{Aabb, Point3};
let b = Aabb::of_point(Point3::new(1.0, 2.0, 3.0));
assert_eq!(b.min, b.max);
assert_eq!(b.extent(), [0.0; 3]);Sourcepub fn intersects(&self, other: &Aabb) -> bool
pub fn intersects(&self, other: &Aabb) -> bool
true when the two boxes share a point, touching included: the
cheap reject before a face pair is intersected. Boxes that only
touch on a face intersect, so a caller that needs a margin
Aabb::inflated one of them by its tolerance first.
use arris_math::Aabb;
let a = Aabb { min: [0.0; 3], max: [1.0; 3] };
let touching = Aabb { min: [1.0, 0.0, 0.0], max: [2.0, 1.0, 1.0] };
let clear = Aabb { min: [1.5, 0.0, 0.0], max: [2.0, 1.0, 1.0] };
assert!(a.intersects(&touching));
assert!(!a.intersects(&clear));Sourcepub fn inflated(&self, by: f64) -> Aabb
pub fn inflated(&self, by: f64) -> Aabb
The box grown by by on every side; a negative by shrinks it,
and never past a point — the centre holds.
use arris_math::Aabb;
let b = Aabb { min: [0.0; 3], max: [2.0; 3] };
assert_eq!(b.inflated(0.5).min, [-0.5; 3]);
assert_eq!(b.inflated(-5.0).extent(), [0.0; 3], "never past a point");Trait Implementations§
impl Copy for Aabb
impl StructuralPartialEq for Aabb
Auto Trait Implementations§
impl Freeze for Aabb
impl RefUnwindSafe for Aabb
impl Send for Aabb
impl Sync for Aabb
impl Unpin for Aabb
impl UnsafeUnpin for Aabb
impl UnwindSafe for Aabb
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.