pub struct Aabb {
pub min: [f64; 3],
pub max: [f64; 3],
}Expand description
Axis-aligned bounding box in 3-D.
Fields§
§min: [f64; 3]Minimum corner.
max: [f64; 3]Maximum corner.
Implementations§
Source§impl Aabb
impl Aabb
Sourcepub fn from_points(pts: &[[f64; 3]]) -> Option<Self>
pub fn from_points(pts: &[[f64; 3]]) -> Option<Self>
Create an AABB from a slice of points (returns None if empty).
Sourcepub fn contains(&self, p: [f64; 3]) -> bool
pub fn contains(&self, p: [f64; 3]) -> bool
Test whether a point is inside (or on the boundary of) this AABB.
Sourcepub fn intersect(&self, other: &Aabb) -> Option<Aabb>
pub fn intersect(&self, other: &Aabb) -> Option<Aabb>
Intersection of two AABBs. Returns None if they do not overlap.
Sourcepub fn expand(&self, amount: f64) -> Aabb
pub fn expand(&self, amount: f64) -> Aabb
Expand (or contract for negative amount) all sides by amount.
Sourcepub fn surface_area(&self) -> f64
pub fn surface_area(&self) -> f64
Surface area of this AABB.
Sourcepub fn half_extents(&self) -> [f64; 3]
pub fn half_extents(&self) -> [f64; 3]
Half-extents of this AABB.
Sourcepub fn intersect_ray(
&self,
origin: [f64; 3],
dir: [f64; 3],
) -> Option<(f64, f64)>
pub fn intersect_ray( &self, origin: [f64; 3], dir: [f64; 3], ) -> Option<(f64, f64)>
Ray–AABB intersection test (slab method).
origin and dir define the ray; dir need not be normalised.
Returns Some((t_enter, t_exit)) if the ray hits, otherwise None.
Only positive-t intersections (in front of the origin) are reported.
Source§impl Aabb
impl Aabb
Sourcepub fn merge(&self, other: &Aabb) -> Aabb
pub fn merge(&self, other: &Aabb) -> Aabb
Merge two AABBs into the smallest AABB containing both.
Alias for Aabb::union.
Sourcepub fn expand_by(&self, amount: f64) -> Aabb
pub fn expand_by(&self, amount: f64) -> Aabb
Expand this AABB by amount in every direction.
Alias for Aabb::expand following the task spec naming.
Sourcepub fn closest_point(&self, p: [f64; 3]) -> [f64; 3]
pub fn closest_point(&self, p: [f64; 3]) -> [f64; 3]
Return the closest point on (or inside) this AABB to p.
Sourcepub fn contains_point_strict(&self, p: [f64; 3]) -> bool
pub fn contains_point_strict(&self, p: [f64; 3]) -> bool
Test whether p is strictly inside (not on the boundary) of this AABB.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.