Struct AxisAlignedBoundingBox

Source
pub struct AxisAlignedBoundingBox<T, D>{ /* private fields */ }

Implementations§

Source§

impl<T, D> AxisAlignedBoundingBox<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>>

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>

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

Source

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

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>) -> T

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>

Source§

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

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T, D> Debug for AxisAlignedBoundingBox<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>

Source§

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

Converts to this type from the input type.
Source§

impl<T, D> PartialEq for AxisAlignedBoundingBox<T, D>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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>

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> StructuralPartialEq for AxisAlignedBoundingBox<T, D>

Auto Trait Implementations§

§

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

§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

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

fn is_in_subset(&self) -> bool

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

fn to_subset_unchecked(&self) -> SS

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

fn from_subset(element: &SS) -> SP

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

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

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