pub struct BoundingBox {
pub min: Vector,
pub max: Vector,
}Expand description
Axis-Aligned Bounding Box (AABB)
Represents a 3D bounding box aligned with the coordinate axes. Commonly used for collision detection and spatial partitioning.
Fields§
§min: VectorMinimum corner of the box
max: VectorMaximum corner of the box
Implementations§
Source§impl BoundingBox
impl BoundingBox
Sourcepub fn new(min: Vector, max: Vector) -> Self
pub fn new(min: Vector, max: Vector) -> Self
Create a new bounding box with the given min and max corners
Sourcepub fn from_center_and_extent(center: Vector, extent: Vector) -> Self
pub fn from_center_and_extent(center: Vector, extent: Vector) -> Self
Create a bounding box from center and extent (half-size)
Sourcepub fn from_point(point: Vector) -> Self
pub fn from_point(point: Vector) -> Self
Create a bounding box from a single point
Sourcepub fn from_points(points: &[Vector]) -> Self
pub fn from_points(points: &[Vector]) -> Self
Create a bounding box that encompasses all given points
Sourcepub fn surface_area(self) -> f32
pub fn surface_area(self) -> f32
Get the surface area of the bounding box
Sourcepub fn contains_point(self, point: Vector) -> bool
pub fn contains_point(self, point: Vector) -> bool
Check if a point is inside the bounding box
Sourcepub fn contains_box(self, other: BoundingBox) -> bool
pub fn contains_box(self, other: BoundingBox) -> bool
Check if another bounding box is completely inside this one
Sourcepub fn intersects(self, other: BoundingBox) -> bool
pub fn intersects(self, other: BoundingBox) -> bool
Check if this bounding box intersects with another
Sourcepub fn expand_to_include(self, point: Vector) -> Self
pub fn expand_to_include(self, point: Vector) -> Self
Expand the bounding box to include a point
Sourcepub fn expand_to_include_box(self, other: BoundingBox) -> Self
pub fn expand_to_include_box(self, other: BoundingBox) -> Self
Expand the bounding box to include another bounding box
Sourcepub fn expand_by(self, amount: f32) -> Self
pub fn expand_by(self, amount: f32) -> Self
Expand the bounding box by a given amount in all directions
Sourcepub fn intersection(self, other: BoundingBox) -> Self
pub fn intersection(self, other: BoundingBox) -> Self
Get the intersection of two bounding boxes
Sourcepub fn transform(self, transform: Transform) -> Self
pub fn transform(self, transform: Transform) -> Self
Transform the bounding box by the given transform
Sourcepub fn distance_to_point(self, point: Vector) -> f32
pub fn distance_to_point(self, point: Vector) -> f32
Get the distance from a point to the bounding box (0 if inside)
Sourcepub fn closest_point_to(self, point: Vector) -> Vector
pub fn closest_point_to(self, point: Vector) -> Vector
Get the closest point on the bounding box to a given point
Trait Implementations§
Source§impl BinarySerializable for BoundingBox
impl BinarySerializable for BoundingBox
Source§impl Clone for BoundingBox
impl Clone for BoundingBox
Source§fn clone(&self) -> BoundingBox
fn clone(&self) -> BoundingBox
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source. Read more