Struct fenris_geometry::AxisAlignedBoundingBox
source · 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>,
impl<T, D> AxisAlignedBoundingBox<T, D>where
T: Scalar + PartialOrd,
D: DimName,
DefaultAllocator: Allocator<T, D>,
source§impl<T, D> AxisAlignedBoundingBox<T, D>where
T: Real,
D: DimName,
DefaultAllocator: Allocator<T, D>,
impl<T, D> AxisAlignedBoundingBox<T, D>where
T: Real,
D: DimName,
DefaultAllocator: Allocator<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>>where
DefaultAllocator: Allocator<usize, D>,
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.
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>where
DefaultAllocator: Allocator<usize, D>,
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.
sourcepub fn max_dist2_to(&self, point: &OPoint<T, D>) -> Twhere
DefaultAllocator: Allocator<usize, D>,
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
.
sourcepub fn max_dist_to(&self, point: &OPoint<T, D>) -> Twhere
DefaultAllocator: Allocator<usize, D>,
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>,
impl<T, D> BoundedGeometry<T> for AxisAlignedBoundingBox<T, D>where
T: Real,
D: DimName,
DefaultAllocator: Allocator<T, D>,
type Dimension = D
fn bounding_box(&self) -> AxisAlignedBoundingBox<T, D>
source§impl<T, D> Clone for AxisAlignedBoundingBox<T, D>where
T: Scalar + Clone,
D: DimName + Clone,
DefaultAllocator: Allocator<T, D>,
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>
fn clone(&self) -> AxisAlignedBoundingBox<T, D>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T, D> Debug for AxisAlignedBoundingBox<T, D>where
T: Scalar + Debug,
D: DimName + Debug,
DefaultAllocator: Allocator<T, D>,
impl<T, D> Debug for AxisAlignedBoundingBox<T, D>where
T: Scalar + Debug,
D: DimName + Debug,
DefaultAllocator: Allocator<T, D>,
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>,
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>,
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>where
T: Scalar + PartialOrd,
D: DimName,
DefaultAllocator: Allocator<T, D>,
impl<T, D> From<OPoint<T, D>> for AxisAlignedBoundingBox<T, D>where
T: Scalar + PartialOrd,
D: DimName,
DefaultAllocator: Allocator<T, D>,
source§impl<T, D> PartialEq<AxisAlignedBoundingBox<T, D>> for AxisAlignedBoundingBox<T, D>where
T: Scalar + PartialEq,
D: DimName + PartialEq,
DefaultAllocator: Allocator<T, D>,
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
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>where
T: Scalar,
D: DimName,
DefaultAllocator: Allocator<T, D>,
OPoint<T, D>: Serialize,
impl<T, D> Serialize for AxisAlignedBoundingBox<T, D>where
T: Scalar,
D: DimName,
DefaultAllocator: Allocator<T, D>,
OPoint<T, D>: Serialize,
impl<T, D> Copy for AxisAlignedBoundingBox<T, D>where
T: Scalar,
D: DimName,
DefaultAllocator: Allocator<T, D>,
OPoint<T, D>: Copy,
impl<T, D> Eq for AxisAlignedBoundingBox<T, D>where
T: Scalar + Eq,
D: DimName + Eq,
DefaultAllocator: Allocator<T, D>,
impl<T, D> StructuralEq for AxisAlignedBoundingBox<T, D>where
T: Scalar,
D: DimName,
DefaultAllocator: Allocator<T, D>,
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§
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§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).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.