Type Alias splashsurf_lib::Aabb3d
source · pub type Aabb3d<R> = AxisAlignedBoundingBox<R, 3>;
Expand description
Convenience type alias for an AABB in three dimensions
Aliased Type§
struct Aabb3d<R> { /* private fields */ }
Implementations§
source§impl<R, const D: usize> AxisAlignedBoundingBox<R, D>where
R: Real,
SVector<R, D>: ThreadSafe,
impl<R, const D: usize> AxisAlignedBoundingBox<R, D>where R: Real, SVector<R, D>: ThreadSafe,
sourcepub fn par_from_points(points: &[SVector<R, D>]) -> Self
pub fn par_from_points(points: &[SVector<R, D>]) -> Self
Constructs the smallest AABB fitting around all the given points, parallel version
source§impl<R, const D: usize> AxisAlignedBoundingBox<R, D>where
R: Real,
impl<R, const D: usize> AxisAlignedBoundingBox<R, D>where R: Real,
sourcepub fn new(min: SVector<R, D>, max: SVector<R, D>) -> Self
pub fn new(min: SVector<R, D>, max: SVector<R, D>) -> Self
Constructs an AABB with the given min and max bounding points
sourcepub fn from_point(point: SVector<R, D>) -> Self
pub fn from_point(point: SVector<R, D>) -> Self
Constructs a degenerate AABB with zero extents centered at the given point
sourcepub fn from_points(points: &[SVector<R, D>]) -> Self
pub fn from_points(points: &[SVector<R, D>]) -> Self
Constructs the smallest AABB fitting around all the given points
use crate::splashsurf_lib::Aabb3d;
use nalgebra::Vector3;
assert_eq!(
Aabb3d::<f64>::from_points(&[]),
Aabb3d::<f64>::zeros()
);
assert_eq!(
Aabb3d::<f64>::from_points(&[Vector3::new(1.0, 1.0, 1.0)]),
Aabb3d::<f64>::from_point(Vector3::new(1.0, 1.0, 1.0))
);
let aabb = Aabb3d::<f64>::from_points(&[
Vector3::new(1.0, 1.0, 1.0),
Vector3::new(0.5, 3.0, 5.0),
Vector3::new(-1.0, 1.0, 1.0)
]);
assert_eq!(aabb.min(), &Vector3::new(-1.0, 1.0, 1.0));
assert_eq!(aabb.max(), &Vector3::new(1.0, 3.0, 5.0));
sourcepub fn try_convert<T>(&self) -> Option<AxisAlignedBoundingBox<T, D>>where
T: Real,
pub fn try_convert<T>(&self) -> Option<AxisAlignedBoundingBox<T, D>>where T: Real,
Tries to convert the AABB from one real type to another real type, returns None if conversion fails
sourcepub fn is_consistent(&self) -> bool
pub fn is_consistent(&self) -> bool
Returns whether the AABB is consistent, i.e. aabb.min()[i] <= aabb.max()[i]
for all i
use crate::splashsurf_lib::Aabb3d;
use nalgebra::Vector3;
assert_eq!(
Aabb3d::<f64>::zeros().is_consistent(), true);
assert_eq!(Aabb3d::new(Vector3::new(-1.0, -1.0, -1.0), Vector3::new(1.0, 1.0, 1.0)).is_consistent(), true);
assert_eq!(Aabb3d::new(Vector3::new(-1.0, 1.0, -1.0), Vector3::new(1.0, -1.0, 1.0)).is_consistent(), false);
sourcepub fn is_degenerate(&self) -> bool
pub fn is_degenerate(&self) -> bool
Returns whether the AABB is degenerate in any dimension, i.e. aabb.min()[i] == aabb.max()[i]
for any i
use crate::splashsurf_lib::Aabb3d;
use nalgebra::Vector3;
assert_eq!(Aabb3d::<f64>::zeros().is_degenerate(), true);
assert_eq!(Aabb3d::new(Vector3::new(1.0, 1.0, 1.0), Vector3::new(1.0, 1.0, 1.0)).is_degenerate(), true);
assert_eq!(Aabb3d::new(Vector3::new(-1.0, 0.0, -3.0), Vector3::new(2.0, 2.0, 4.0)).is_degenerate(), false);
sourcepub fn extents(&self) -> SVector<R, D>
pub fn extents(&self) -> SVector<R, D>
Returns the extents of the bounding box (vector connecting min and max point of the box)
use crate::splashsurf_lib::Aabb3d;
use nalgebra::Vector3;
assert_eq!(Aabb3d::<f64>::zeros().extents(), Vector3::new(0.0, 0.0, 0.0));
assert_eq!(Aabb3d::new(Vector3::new(-1.0, -1.0, -1.0), Vector3::new(1.0, 1.0, 1.0)).extents(), Vector3::new(2.0, 2.0, 2.0));
assert_eq!(Aabb3d::new(Vector3::new(-1.0, 0.0, -3.0), Vector3::new(2.0, 2.0, 4.0)).extents(), Vector3::new(3.0, 2.0, 7.0));
assert_eq!(Aabb3d::new(Vector3::new(-1.0, 5.0, -3.0), Vector3::new(2.0, 15.0, 4.0)).extents(), Vector3::new(3.0, 10.0, 7.0));
sourcepub fn min_extent(&self) -> R
pub fn min_extent(&self) -> R
Returns the smallest scalar extent of the AABB over all of its dimensions
use crate::splashsurf_lib::Aabb3d;
use nalgebra::Vector3;
assert_eq!(Aabb3d::<f64>::zeros().min_extent(), 0.0);
assert_eq!(Aabb3d::new(Vector3::new(-1.0, -2.0, -3.0), Vector3::new(2.0, 3.0, 4.0)).min_extent(), 3.0);
assert_eq!(Aabb3d::new(Vector3::new(-1.0, 0.0, -3.0), Vector3::new(2.0, 2.0, 4.0)).min_extent(), 2.0);
assert_eq!(Aabb3d::new(Vector3::new(-1.0, 0.0, 1.0), Vector3::new(2.0, 1.0, 1.0)).min_extent(), 0.0);
sourcepub fn max_extent(&self) -> R
pub fn max_extent(&self) -> R
Returns the largest scalar extent of the AABB over all of its dimensions
use crate::splashsurf_lib::Aabb3d;
use nalgebra::Vector3;
assert_eq!(Aabb3d::<f64>::zeros().max_extent(), 0.0);
assert_eq!(Aabb3d::new(Vector3::new(-10.0, 0.0, -3.0), Vector3::new(2.0, 2.0, 4.0)).max_extent(), 12.0);
assert_eq!(Aabb3d::new(Vector3::new(-1.0, -2.0, -3.0), Vector3::new(2.0, 3.0, 4.0)).max_extent(), 7.0);
assert_eq!(Aabb3d::new(Vector3::new(-1.0, 5.0, -3.0), Vector3::new(2.0, 15.0, 4.0)).max_extent(), 10.0);
sourcepub fn centroid(&self) -> SVector<R, D>
pub fn centroid(&self) -> SVector<R, D>
Returns the geometric centroid of the AABB (mean of the corner points)
sourcepub fn contains_aabb(&self, other: &Self) -> bool
pub fn contains_aabb(&self, other: &Self) -> bool
Checks if the given AABB is inside of the AABB, the AABB is considered to be half-open to its max coordinate
sourcepub fn contains_point(&self, point: &SVector<R, D>) -> bool
pub fn contains_point(&self, point: &SVector<R, D>) -> bool
Checks if the given point is inside of the AABB, the AABB is considered to be half-open to its max coordinate
sourcepub fn center_at_origin(&mut self)
pub fn center_at_origin(&mut self)
Translates the AABB to center it at the coordinate origin (moves the centroid to the coordinate origin)
sourcepub fn scale_uniformly(&mut self, scaling: R)
pub fn scale_uniformly(&mut self, scaling: R)
Multiplies a uniform, local scaling to the AABB (i.e. multiplying its extents as if it was centered at the origin)
sourcepub fn join(&mut self, other: &Self)
pub fn join(&mut self, other: &Self)
Enlarges this AABB to the smallest AABB enclosing both itself and another AABB
sourcepub fn join_with_point(&mut self, point: &SVector<R, D>)
pub fn join_with_point(&mut self, point: &SVector<R, D>)
Enlarges this AABB to the smallest AABB enclosing both itself and another point
sourcepub fn grow_uniformly(&mut self, margin: R)
pub fn grow_uniformly(&mut self, margin: R)
Grows this AABB uniformly in all directions by the given scalar margin (i.e. adding the margin to min/max extents)
sourcepub fn enclosing_cube(&self) -> Self
pub fn enclosing_cube(&self) -> Self
Returns the smallest cubical AABB with the same center that encloses this AABB
Trait Implementations§
source§impl<R: Clone + Real, const D: usize> Clone for AxisAlignedBoundingBox<R, D>
impl<R: Clone + Real, const D: usize> Clone for AxisAlignedBoundingBox<R, D>
source§fn clone(&self) -> AxisAlignedBoundingBox<R, D>
fn clone(&self) -> AxisAlignedBoundingBox<R, D>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<R: PartialEq + Real, const D: usize> PartialEq<AxisAlignedBoundingBox<R, D>> for AxisAlignedBoundingBox<R, D>
impl<R: PartialEq + Real, const D: usize> PartialEq<AxisAlignedBoundingBox<R, D>> for AxisAlignedBoundingBox<R, D>
source§fn eq(&self, other: &AxisAlignedBoundingBox<R, D>) -> bool
fn eq(&self, other: &AxisAlignedBoundingBox<R, D>) -> bool
self
and other
values to be equal, and is used
by ==
.