pub struct AxisAlignedBoundingBox<R: Scalar, const D: usize> { /* private fields */ }Expand description
Type representing an axis aligned bounding box in arbitrary dimensions
Implementations§
Source§impl<R, const D: usize> AxisAlignedBoundingBox<R, D>
impl<R, const D: usize> AxisAlignedBoundingBox<R, D>
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 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 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 + Scalar, const D: usize> Clone for AxisAlignedBoundingBox<R, D>
impl<R: Clone + Scalar, 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<'de, R, const D: usize> Deserialize<'de> for AxisAlignedBoundingBox<R, D>where
R: Deserialize<'de> + Scalar,
impl<'de, R, const D: usize> Deserialize<'de> for AxisAlignedBoundingBox<R, D>where
R: Deserialize<'de> + Scalar,
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>,
Source§impl<R: PartialEq + Scalar, const D: usize> PartialEq for AxisAlignedBoundingBox<R, D>
impl<R: PartialEq + Scalar, const D: usize> PartialEq 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 ==.Source§impl<R, const D: usize> Serialize for AxisAlignedBoundingBox<R, D>
impl<R, const D: usize> Serialize for AxisAlignedBoundingBox<R, D>
impl<R: Eq + Scalar, const D: usize> Eq for AxisAlignedBoundingBox<R, D>
impl<R: Scalar, const D: usize> StructuralPartialEq for AxisAlignedBoundingBox<R, D>
Auto Trait Implementations§
impl<R, const D: usize> Freeze for AxisAlignedBoundingBox<R, D>where
R: Freeze,
impl<R, const D: usize> RefUnwindSafe for AxisAlignedBoundingBox<R, D>where
R: RefUnwindSafe,
impl<R, const D: usize> Send for AxisAlignedBoundingBox<R, D>where
R: Send,
impl<R, const D: usize> Sync for AxisAlignedBoundingBox<R, D>where
R: Sync,
impl<R, const D: usize> Unpin for AxisAlignedBoundingBox<R, D>where
R: Unpin,
impl<R, const D: usize> UnwindSafe for AxisAlignedBoundingBox<R, D>where
R: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.