pub struct AxisAlignedBoundingBox<T, D>where
    T: Scalar,
    D: DimName,
    DefaultAllocator: Allocator<T, D>,
{ /* private fields */ }

Implementations§

source§

impl<T, D> AxisAlignedBoundingBox<T, D>where
    T: Scalar + PartialOrd,
    D: DimName,
    DefaultAllocator: Allocator<T, D>,

source

pub fn new(min: OPoint<T, D>, max: OPoint<T, D>) -> Self

source

pub fn min(&self) -> &OPoint<T, D>

source

pub fn max(&self) -> &OPoint<T, D>

source§

impl<T, D> AxisAlignedBoundingBox<T, D>where
    T: Real,
    D: DimName,
    DefaultAllocator: Allocator<T, D>,

source

pub fn enclose(&self, other: &AxisAlignedBoundingBox<T, D>) -> Self

Computes the minimal bounding box which encloses both self and other.

source

pub fn from_points<'a>(
    points: impl IntoIterator<Item = &'a OPoint<T, D>>
) -> Option<Self>

source

pub fn extents(&self) -> OVector<T, D>

source

pub fn max_extent(&self) -> T

source

pub fn center(&self) -> OPoint<T, D>

source

pub fn uniformly_scale(&self, scale: T) -> Self

Uniformly scales each axis by the given scale amount, with respect to the center of the box.

use nalgebra::{point, vector};
use matrixcompare::assert_matrix_eq;

let aabb = AxisAlignedBoundingBox::new(point![0.0, 0.0], point![1.0, 1.0]);
let scaled = aabb.uniformly_scale(0.5);

assert_matrix_eq!(scaled.min().coords, vector![0.25, 0.25], comp = float);
assert_matrix_eq!(scaled.max().coords, vector![0.75, 0.75], comp = float);
source

pub fn contains_point(&self, point: &OPoint<T, D>) -> bool

source

pub fn intersects(&self, other: &Self) -> bool

source

pub fn grow_uniformly(&self, distance: T) -> Self

Grows the bounding box by distance in all directions.

Examples
let aabb = AxisAlignedBoundingBox::new(point![0.0, 0.0], point![1.0, 1.0]);
let grown = aabb.grow_uniformly(1.0);
assert_eq!(grown.min(), &point![-1.0, -1.0]);
assert_eq!(grown.max(), &point![2.0, 2.0]);
source

pub fn corners_iter<'a>(&'a self) -> impl 'a + Iterator<Item = OPoint<T, D>>where
    DefaultAllocator: Allocator<usize, D>,

Creates an iterator over the corners of the bounding box.

source

pub fn closest_point_to(&self, point: &OPoint<T, D>) -> OPoint<T, D>

Computes the point in the bounding box closest to the given point.

source

pub fn dist_to(&self, point: &OPoint<T, D>) -> T

Computes the distance between the bounding box and the given point.

source

pub fn dist2_to(&self, point: &OPoint<T, D>) -> T

Computes the squared distance between the bounding box and the given point.

source

pub fn furthest_point_to(&self, point: &OPoint<T, D>) -> OPoint<T, D>where
    DefaultAllocator: Allocator<usize, D>,

Compute the point in the bounding box furthest away from the given point.

source

pub fn max_dist2_to(&self, point: &OPoint<T, D>) -> Twhere
    DefaultAllocator: Allocator<usize, D>,

The squared distance to the point in the bounding box furthest away from the given point.

Panics

Panic behavior is identical to furthest_point_to.

source

pub fn max_dist_to(&self, point: &OPoint<T, D>) -> Twhere
    DefaultAllocator: Allocator<usize, D>,

The distance to the point in the bounding box furthest away from the given point.

Panics

Panic behavior is identical to max_dist2_to.

Trait Implementations§

source§

impl<T, D> BoundedGeometry<T> for AxisAlignedBoundingBox<T, D>where
    T: Real,
    D: DimName,
    DefaultAllocator: Allocator<T, D>,

source§

impl<T, D> Clone for AxisAlignedBoundingBox<T, D>where
    T: Scalar + Clone,
    D: DimName + Clone,
    DefaultAllocator: Allocator<T, D>,

source§

fn clone(&self) -> AxisAlignedBoundingBox<T, 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<T, D> Debug for AxisAlignedBoundingBox<T, D>where
    T: Scalar + Debug,
    D: DimName + Debug,
    DefaultAllocator: Allocator<T, D>,

source§

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

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

impl<'de, T, D> Deserialize<'de> for AxisAlignedBoundingBox<T, D>where
    T: Scalar,
    D: DimName,
    DefaultAllocator: Allocator<T, D>,
    OPoint<T, D>: Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
    __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T, D> From<OPoint<T, D>> for AxisAlignedBoundingBox<T, D>where
    T: Scalar + PartialOrd,
    D: DimName,
    DefaultAllocator: Allocator<T, D>,

source§

fn from(point: OPoint<T, D>) -> Self

Converts to this type from the input type.
source§

impl<T, D> PartialEq<AxisAlignedBoundingBox<T, D>> for AxisAlignedBoundingBox<T, D>where
    T: Scalar + PartialEq,
    D: DimName + PartialEq,
    DefaultAllocator: Allocator<T, D>,

source§

fn eq(&self, other: &AxisAlignedBoundingBox<T, 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<T, D> Serialize for AxisAlignedBoundingBox<T, D>where
    T: Scalar,
    D: DimName,
    DefaultAllocator: Allocator<T, D>,
    OPoint<T, D>: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where
    __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T, D> Copy for AxisAlignedBoundingBox<T, D>where
    T: Scalar,
    D: DimName,
    DefaultAllocator: Allocator<T, D>,
    OPoint<T, D>: Copy,

source§

impl<T, D> Eq for AxisAlignedBoundingBox<T, D>where
    T: Scalar + Eq,
    D: DimName + Eq,
    DefaultAllocator: Allocator<T, D>,

source§

impl<T, D> StructuralEq for AxisAlignedBoundingBox<T, D>where
    T: Scalar,
    D: DimName,
    DefaultAllocator: Allocator<T, D>,

source§

impl<T, D> StructuralPartialEq for AxisAlignedBoundingBox<T, D>where
    T: Scalar,
    D: DimName,
    DefaultAllocator: Allocator<T, D>,

Auto Trait Implementations§

§

impl<T, D> !RefUnwindSafe for AxisAlignedBoundingBox<T, D>

§

impl<T, D> !Send for AxisAlignedBoundingBox<T, D>

§

impl<T, D> !Sync for AxisAlignedBoundingBox<T, D>

§

impl<T, D> !Unpin for AxisAlignedBoundingBox<T, D>

§

impl<T, D> !UnwindSafe for AxisAlignedBoundingBox<T, D>

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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.

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.
const: unstable · 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.
const: unstable · source§

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

Performs the conversion.
source§

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