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,

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>