pub struct AxisAlignedBoundingBox<R: Real, 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>where R: Real, SVector<R, D>: ThreadSafe,

source

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,

source

pub fn zeros() -> Self

Constructs a degenerate AABB with min and max set to zero

source

pub fn new(min: SVector<R, D>, max: SVector<R, D>) -> Self

Constructs an AABB with the given min and max bounding points

source

pub fn from_point(point: SVector<R, D>) -> Self

Constructs a degenerate AABB with zero extents centered at the given point

source

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));
source

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

source

pub fn min(&self) -> &SVector<R, D>

Returns the min coordinate of the bounding box

source

pub fn max(&self) -> &SVector<R, D>

Returns the max coordinate of the bounding box

source

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);
source

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);
source

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));
source

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);
source

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);
source

pub fn centroid(&self) -> SVector<R, D>

Returns the geometric centroid of the AABB (mean of the corner points)

source

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

source

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

source

pub fn translate(&mut self, vector: &SVector<R, D>)

Translates the AABB by the given vector

source

pub fn center_at_origin(&mut self)

Translates the AABB to center it at the coordinate origin (moves the centroid to the coordinate origin)

source

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)

source

pub fn join(&mut self, other: &Self)

Enlarges this AABB to the smallest AABB enclosing both itself and another AABB

source

pub fn join_with_point(&mut self, point: &SVector<R, D>)

Enlarges this AABB to the smallest AABB enclosing both itself and another point

source

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)

source

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>

source§

fn clone(&self) -> AxisAlignedBoundingBox<R, D>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<R, const D: usize> Debug for AxisAlignedBoundingBox<R, D>where R: Real,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<R: PartialEq + Real, const D: usize> PartialEq<AxisAlignedBoundingBox<R, D>> for AxisAlignedBoundingBox<R, D>

source§

fn eq(&self, other: &AxisAlignedBoundingBox<R, D>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<R: Eq + Real, const D: usize> Eq for AxisAlignedBoundingBox<R, D>

source§

impl<R: Real, const D: usize> StructuralEq for AxisAlignedBoundingBox<R, D>

source§

impl<R: Real, const D: usize> StructuralPartialEq for AxisAlignedBoundingBox<R, D>

Auto Trait Implementations§

§

impl<R, const D: usize> RefUnwindSafe for AxisAlignedBoundingBox<R, D>where R: RefUnwindSafe,

§

impl<R, const D: usize> Send for AxisAlignedBoundingBox<R, D>

§

impl<R, const D: usize> Sync for AxisAlignedBoundingBox<R, D>

§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> Scalar for Twhere T: 'static + Clone + PartialEq<T> + Debug,

source§

impl<T> ThreadSafe for Twhere T: Sync + Send,