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 line_intersects(self, origin: Point3, dir: Vec3) -> bool
pub fn line_intersects(self, origin: Point3, dir: Vec3) -> bool
Whether the whole line through origin along dir, both ways,
meets this box (touching counts).
A zero direction component is tested by the origin’s coordinate alone, so an origin lying on a face of the box with the line in that face still meets it.
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.