pub struct Aabb {
pub min: Vec3,
pub max: Vec3,
}Expand description
An axis-aligned bounding box in whichever space its points came from.
The empty box has min > max on every axis, so extending it with the
first point produces a degenerate box at that point, and a union with any
box returns the other operand.
Fields§
§min: Vec3Componentwise minimum corner.
max: Vec3Componentwise maximum corner.
Implementations§
Source§impl Aabb
impl Aabb
Sourcepub const fn new(min: Vec3, max: Vec3) -> Self
pub const fn new(min: Vec3, max: Vec3) -> Self
Builds a box from explicit corners; callers guarantee min <= max.
Sourcepub fn from_points(points: impl IntoIterator<Item = Vec3>) -> Self
pub fn from_points(points: impl IntoIterator<Item = Vec3>) -> Self
Builds the tightest box over a set of points, O(n).
Non-finite coordinates are skipped so one bad atom cannot poison the
bound of a whole structure.
Sourcepub fn extend(&mut self, point: Vec3)
pub fn extend(&mut self, point: Vec3)
Grows the box to contain point; non-finite points are ignored.
Sourcepub fn extend_sphere(&mut self, center: Vec3, radius: f32)
pub fn extend_sphere(&mut self, center: Vec3, radius: f32)
Grows the box to contain a sphere of radius around center.
Sourcepub fn overlaps(&self, other: &Self) -> bool
pub fn overlaps(&self, other: &Self) -> bool
True when two non-empty boxes share any volume or boundary.
Sourcepub fn half_extents(&self) -> Vec3
pub fn half_extents(&self) -> Vec3
Half the diagonal extent on each axis.
Sourcepub fn corners(&self) -> [Vec3; 8]
pub fn corners(&self) -> [Vec3; 8]
The eight corner points, fixed order (x fastest, then y, then z).
Sourcepub fn transform(&self, matrix: &Mat4) -> Self
pub fn transform(&self, matrix: &Mat4) -> Self
The tightest axis-aligned box containing this box after an affine transform: the transformed corners’ bound.
Sourcepub fn ray_intersect(&self, origin: Vec3, inv_dir: Vec3) -> Option<(f32, f32)>
pub fn ray_intersect(&self, origin: Vec3, inv_dir: Vec3) -> Option<(f32, f32)>
Slab test: the parametric interval where a ray overlaps the box, or
None when it misses. inv_dir is the componentwise reciprocal of
the ray direction (infinities from zero components behave correctly).
Sourcepub fn bounding_sphere(&self) -> BoundingSphere
pub fn bounding_sphere(&self) -> BoundingSphere
The bounding sphere of the box: centered, radius to a corner.
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more