pub struct AxisAlignedBoundingBox<T, D>{ /* private fields */ }
Implementations§
Source§impl<T, D> AxisAlignedBoundingBox<T, D>
impl<T, D> AxisAlignedBoundingBox<T, D>
Source§impl<T, D> AxisAlignedBoundingBox<T, D>
impl<T, D> AxisAlignedBoundingBox<T, D>
Sourcepub fn enclose(&self, other: &AxisAlignedBoundingBox<T, D>) -> Self
pub fn enclose(&self, other: &AxisAlignedBoundingBox<T, D>) -> Self
Computes the minimal bounding box which encloses both self
and other
.
pub fn from_points<'a>( points: impl IntoIterator<Item = &'a OPoint<T, D>>, ) -> Option<Self>
pub fn extents(&self) -> OVector<T, D>
pub fn max_extent(&self) -> T
pub fn center(&self) -> OPoint<T, D>
Sourcepub fn uniformly_scale(&self, scale: T) -> Self
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);
pub fn contains_point(&self, point: &OPoint<T, D>) -> bool
pub fn intersects(&self, other: &Self) -> bool
Sourcepub fn grow_uniformly(&self, distance: T) -> Self
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]);
Sourcepub fn corners_iter<'a>(&'a self) -> impl 'a + Iterator<Item = OPoint<T, D>>
pub fn corners_iter<'a>(&'a self) -> impl 'a + Iterator<Item = OPoint<T, D>>
Creates an iterator over the corners of the bounding box.
Sourcepub fn closest_point_to(&self, point: &OPoint<T, D>) -> OPoint<T, D>
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.
Sourcepub fn dist_to(&self, point: &OPoint<T, D>) -> T
pub fn dist_to(&self, point: &OPoint<T, D>) -> T
Computes the distance between the bounding box and the given point.
Sourcepub fn dist2_to(&self, point: &OPoint<T, D>) -> T
pub fn dist2_to(&self, point: &OPoint<T, D>) -> T
Computes the squared distance between the bounding box and the given point.
Sourcepub fn furthest_point_to(&self, point: &OPoint<T, D>) -> OPoint<T, D>
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.
Sourcepub fn max_dist2_to(&self, point: &OPoint<T, D>) -> T
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
.
Sourcepub fn max_dist_to(&self, point: &OPoint<T, D>) -> T
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>
impl<T, D> BoundedGeometry<T> for AxisAlignedBoundingBox<T, D>
type Dimension = D
fn bounding_box(&self) -> AxisAlignedBoundingBox<T, D>
Source§impl<T, D> Clone for AxisAlignedBoundingBox<T, D>
impl<T, D> Clone for AxisAlignedBoundingBox<T, D>
Source§fn clone(&self) -> AxisAlignedBoundingBox<T, D>
fn clone(&self) -> AxisAlignedBoundingBox<T, D>
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T, D> Debug for AxisAlignedBoundingBox<T, D>
impl<T, D> Debug for AxisAlignedBoundingBox<T, D>
Source§impl<'de, T, D> Deserialize<'de> for AxisAlignedBoundingBox<T, D>
impl<'de, T, D> Deserialize<'de> for AxisAlignedBoundingBox<T, D>
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<T, D> From<OPoint<T, D>> for AxisAlignedBoundingBox<T, D>
impl<T, D> From<OPoint<T, D>> for AxisAlignedBoundingBox<T, D>
Source§impl<T, D> PartialEq for AxisAlignedBoundingBox<T, D>
impl<T, D> PartialEq for AxisAlignedBoundingBox<T, D>
Source§fn eq(&self, other: &AxisAlignedBoundingBox<T, D>) -> bool
fn eq(&self, other: &AxisAlignedBoundingBox<T, D>) -> bool
self
and other
values to be equal, and is used by ==
.Source§impl<T, D> Serialize for AxisAlignedBoundingBox<T, D>
impl<T, D> Serialize for AxisAlignedBoundingBox<T, D>
impl<T, D> Copy for AxisAlignedBoundingBox<T, D>
impl<T, D> Eq for AxisAlignedBoundingBox<T, D>
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> 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<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<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.