Struct valence_math::Aabb
source · pub struct Aabb { /* private fields */ }
Expand description
A three-dimensional axis-aligned bounding box, or “AABB”.
The AABB is defined by two points—min
and max
. min
is less than or
equal to max
componentwise.
Implementations§
source§impl Aabb
impl Aabb
pub const ZERO: Self = _
sourcepub fn new(min: DVec3, max: DVec3) -> Self
pub fn new(min: DVec3, max: DVec3) -> Self
Constructs a new AABB from min
and max
points.
§Panics
Panics if debug_assertions
are enabled and min
is not less than or
equal to max
componentwise.
pub fn from_bottom_size(bottom: DVec3, size: DVec3) -> Self
pub const fn min(self) -> DVec3
pub const fn max(self) -> DVec3
pub fn union(self, other: Self) -> Self
pub fn intersects(self, other: Self) -> bool
sourcepub fn contains_point(self, p: DVec3) -> bool
pub fn contains_point(self, p: DVec3) -> bool
Does this bounding box contain the given point?
sourcepub fn projected_point(self, p: DVec3) -> DVec3
pub fn projected_point(self, p: DVec3) -> DVec3
Returns the closest point in the AABB to the given point.
sourcepub fn distance_to_point(self, p: DVec3) -> f64
pub fn distance_to_point(self, p: DVec3) -> f64
Returns the smallest distance from the AABB to the point.
sourcepub fn ray_intersection(
self,
origin: DVec3,
direction: DVec3,
) -> Option<[f64; 2]>
pub fn ray_intersection( self, origin: DVec3, direction: DVec3, ) -> Option<[f64; 2]>
Calculates the intersection between this AABB and a ray
defined by its origin
point and direction
vector.
If an intersection occurs, Some([near, far])
is returned. near
and
far
are the values of t
in the equation origin + t * direction = point
where point
is the nearest or furthest intersection point to
the origin
. If no intersection occurs, then None
is returned.
In other words, if direction
is normalized, then near
and far
are
the distances to the nearest and furthest intersection points.
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 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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)