pub struct Aabb3 {
pub min: Point3,
pub max: Point3,
}Expand description
A 3D axis-aligned bounding box.
Fields§
§min: Point3Minimum corner.
max: Point3Maximum corner.
Implementations§
Source§impl Aabb3
impl Aabb3
Sourcepub fn from_points(points: impl IntoIterator<Item = Point3>) -> Self
pub fn from_points(points: impl IntoIterator<Item = Point3>) -> Self
Create an AABB from an iterator of points.
§Panics
Panics if the iterator is empty. Use Aabb3::try_from_points for
a fallible version.
Sourcepub fn try_from_points(points: impl IntoIterator<Item = Point3>) -> Option<Self>
pub fn try_from_points(points: impl IntoIterator<Item = Point3>) -> Option<Self>
Create an AABB from an iterator of points, returning None if empty.
Sourcepub fn intersects(self, other: Self) -> bool
pub fn intersects(self, other: Self) -> bool
Whether this box intersects another.
Sourcepub fn contains_point(self, p: Point3) -> bool
pub fn contains_point(self, p: Point3) -> bool
Whether this box contains a point.
Sourcepub fn surface_area(self) -> f64
pub fn surface_area(self) -> f64
Surface area of the box (used for SAH cost in BVH).
Sourcepub fn ray_intersects(self, origin: Point3, inv_dir: Vec3) -> bool
pub fn ray_intersects(self, origin: Point3, inv_dir: Vec3) -> bool
Test whether a ray (origin + positive-t direction) intersects this box.
Uses the slab method. Returns true if the ray hits the box at any
t >= 0.
Sourcepub fn distance_squared_to_point(self, p: Point3) -> f64
pub fn distance_squared_to_point(self, p: Point3) -> f64
Squared distance from a point to the closest point on the box.
Trait Implementations§
impl Copy for Aabb3
Source§impl<'de> Deserialize<'de> for Aabb3
impl<'de> Deserialize<'de> for Aabb3
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Aabb3
Auto Trait Implementations§
impl Freeze for Aabb3
impl RefUnwindSafe for Aabb3
impl Send for Aabb3
impl Sync for Aabb3
impl Unpin for Aabb3
impl UnsafeUnpin for Aabb3
impl UnwindSafe for Aabb3
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