Struct tri_mesh::AxisAlignedBoundingBox
source · pub struct AxisAlignedBoundingBox { /* private fields */ }
Expand description
A bounding box that aligns with the x, y and z axes.
Implementations
sourceimpl AxisAlignedBoundingBox
impl AxisAlignedBoundingBox
sourcepub const EMPTY: AxisAlignedBoundingBox = Self{
min:
Vec3::new(std::f32::INFINITY, std::f32::INFINITY, std::f32::INFINITY),
max:
Vec3::new(std::f32::NEG_INFINITY, std::f32::NEG_INFINITY,
std::f32::NEG_INFINITY),}
pub const EMPTY: AxisAlignedBoundingBox = Self{ min: Vec3::new(std::f32::INFINITY, std::f32::INFINITY, std::f32::INFINITY), max: Vec3::new(std::f32::NEG_INFINITY, std::f32::NEG_INFINITY, std::f32::NEG_INFINITY),}
An empty bounding box.
sourcepub const INFINITE: AxisAlignedBoundingBox = Self{
min:
Vec3::new(std::f32::NEG_INFINITY, std::f32::NEG_INFINITY,
std::f32::NEG_INFINITY),
max:
Vec3::new(std::f32::INFINITY, std::f32::INFINITY,
std::f32::INFINITY),}
pub const INFINITE: AxisAlignedBoundingBox = Self{ min: Vec3::new(std::f32::NEG_INFINITY, std::f32::NEG_INFINITY, std::f32::NEG_INFINITY), max: Vec3::new(std::f32::INFINITY, std::f32::INFINITY, std::f32::INFINITY),}
An infinitely large bounding box.
sourcepub fn new_with_positions(positions: &[Vector3<f32>]) -> AxisAlignedBoundingBox
pub fn new_with_positions(positions: &[Vector3<f32>]) -> AxisAlignedBoundingBox
Constructs a new bounding box and expands it such that all of the given positions are contained inside the bounding box.
sourcepub fn new_with_transformed_positions(
positions: &[Vector3<f32>],
transformation: &Matrix4<f32>
) -> AxisAlignedBoundingBox
pub fn new_with_transformed_positions(
positions: &[Vector3<f32>],
transformation: &Matrix4<f32>
) -> AxisAlignedBoundingBox
Constructs a new bounding box and expands it such that all of the given positions transformed with the given transformation are contained inside the bounding box. A position consisting of an x, y and z coordinate corresponds to three consecutive value in the positions array.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the bounding box is empty (ie. constructed by AxisAlignedBoundingBox::EMPTY).
sourcepub fn is_infinite(&self) -> bool
pub fn is_infinite(&self) -> bool
Returns true if the bounding box is infinitely large (ie. constructed by AxisAlignedBoundingBox::INFINITE).
sourcepub fn expand(&mut self, positions: &[Vector3<f32>])
pub fn expand(&mut self, positions: &[Vector3<f32>])
Expands the bounding box such that all of the given positions are contained inside the bounding box. A position consisting of an x, y and z coordinate corresponds to three consecutive value in the positions array.
sourcepub fn expand_with_transformation(
&mut self,
positions: &[Vector3<f32>],
transformation: &Matrix4<f32>
)
pub fn expand_with_transformation(
&mut self,
positions: &[Vector3<f32>],
transformation: &Matrix4<f32>
)
Expands the bounding box such that all of the given positions transformed with the given transformation are contained inside the bounding box. A position consisting of an x, y and z coordinate corresponds to three consecutive value in the positions array.
sourcepub fn expand_with_aabb(&mut self, other: &AxisAlignedBoundingBox)
pub fn expand_with_aabb(&mut self, other: &AxisAlignedBoundingBox)
Expand the bounding box such that it also contains the given other bounding box.
sourcepub fn transform(&mut self, transformation: &Matrix4<f32>)
pub fn transform(&mut self, transformation: &Matrix4<f32>)
Transforms the bounding box by the given transformation.
Note: Use new_with_transformed_positions instead of new_with_positions followed by this method to create a more tight bounding box.
sourcepub fn distance(&self, position: &Vector3<f32>) -> f32
pub fn distance(&self, position: &Vector3<f32>) -> f32
The distance from position to the point in this bounding box that is closest to position.
sourcepub fn distance_max(&self, position: &Vector3<f32>) -> f32
pub fn distance_max(&self, position: &Vector3<f32>) -> f32
The distance from position to the point in this bounding box that is furthest away from position.
Trait Implementations
sourceimpl Clone for AxisAlignedBoundingBox
impl Clone for AxisAlignedBoundingBox
sourcefn clone(&self) -> AxisAlignedBoundingBox
fn clone(&self) -> AxisAlignedBoundingBox
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more