pub struct AABB<P> where
P: Point, { /* private fields */ }
Expand description
An n-dimensional axis aligned bounding box (AABB).
An object’s AABB is the smallest box totally encompassing an object while being aligned to the current coordinate system. Although these structures are commonly called bounding boxes, they exist in any dimension.
Note that AABBs cannot be inserted into r-trees. Use the Rectangle struct for this purpose.
Type arguments
P
: The struct is generic over which point type is used. Using an n-dimensional point
type will result in an n-dimensional bounding box.
Implementations
sourceimpl<P> AABB<P> where
P: Point,
impl<P> AABB<P> where
P: Point,
sourcepub fn from_point(p: P) -> Self
pub fn from_point(p: P) -> Self
Returns the AABB encompassing a single point.
sourcepub fn lower(&self) -> P
pub fn lower(&self) -> P
Returns the AABB’s lower corner.
This is the point contained within the AABB with the smallest coordinate value in each dimension.
sourcepub fn upper(&self) -> P
pub fn upper(&self) -> P
Returns the AABB’s upper corner.
This is the point contained within the AABB with the largest coordinate value in each dimension.
sourcepub fn from_corners(p1: P, p2: P) -> Self
pub fn from_corners(p1: P, p2: P) -> Self
Creates a new AABB encompassing two points.
sourcepub fn from_points<'a, I>(i: I) -> Self where
I: IntoIterator<Item = &'a P> + 'a,
P: 'a,
pub fn from_points<'a, I>(i: I) -> Self where
I: IntoIterator<Item = &'a P> + 'a,
P: 'a,
Creates a new AABB encompassing a collection of points.
sourcepub fn min_point(&self, point: &P) -> P
pub fn min_point(&self, point: &P) -> P
Returns the point within this AABB closest to a given point.
If point
is contained within the AABB, point
will be returned.
sourcepub fn distance_2(&self, point: &P) -> P::Scalar
pub fn distance_2(&self, point: &P) -> P::Scalar
Returns the squared distance to the AABB’s min_point
Trait Implementations
sourceimpl<P> Envelope for AABB<P> where
P: Point,
impl<P> Envelope for AABB<P> where
P: Point,
type Point = P
type Point = P
The envelope’s point type.
sourcefn contains_point(&self, point: &P) -> bool
fn contains_point(&self, point: &P) -> bool
Returns true if a point is contained within this envelope.
sourcefn contains_envelope(&self, other: &Self) -> bool
fn contains_envelope(&self, other: &Self) -> bool
Returns true if another envelope is fully contained within self
.
sourcefn merged(&self, other: &Self) -> Self
fn merged(&self, other: &Self) -> Self
Returns the minimal envelope containing self
and another envelope.
sourcefn intersects(&self, other: &Self) -> bool
fn intersects(&self, other: &Self) -> bool
Sets self
to the intersection of self
and another envelope.
sourcefn distance_2(&self, point: &P) -> P::Scalar
fn distance_2(&self, point: &P) -> P::Scalar
Returns the euclidean distance to the envelope’s border.
sourcefn min_max_dist_2(&self, point: &P) -> <P as Point>::Scalar
fn min_max_dist_2(&self, point: &P) -> <P as Point>::Scalar
Returns the squared min-max distance, a concept that helps to find nearest neighbors efficiently. Read more
sourcefn intersection_area(&self, other: &Self) -> <Self::Point as Point>::Scalar
fn intersection_area(&self, other: &Self) -> <Self::Point as Point>::Scalar
Returns the area of the intersection of self
and another envelope.
sourcefn perimeter_value(&self) -> P::Scalar
fn perimeter_value(&self) -> P::Scalar
Returns a value proportional to the envelope’s perimeter.
sourcefn sort_envelopes<T: RTreeObject<Envelope = Self>>(
axis: usize,
envelopes: &mut [T]
)
fn sort_envelopes<T: RTreeObject<Envelope = Self>>(
axis: usize,
envelopes: &mut [T]
)
Sorts a given set of objects with envelopes along one of their axes.
sourcefn partition_envelopes<T: RTreeObject<Envelope = Self>>(
axis: usize,
envelopes: &mut [T],
selection_size: usize
)
fn partition_envelopes<T: RTreeObject<Envelope = Self>>(
axis: usize,
envelopes: &mut [T],
selection_size: usize
)
Partitions objects with an envelope along a certain axis. Read more
sourceimpl<P: Ord> Ord for AABB<P> where
P: Point,
impl<P: Ord> Ord for AABB<P> where
P: Point,
sourceimpl<P: PartialOrd> PartialOrd<AABB<P>> for AABB<P> where
P: Point,
impl<P: PartialOrd> PartialOrd<AABB<P>> for AABB<P> where
P: Point,
sourcefn partial_cmp(&self, other: &AABB<P>) -> Option<Ordering>
fn partial_cmp(&self, other: &AABB<P>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<P: Copy> Copy for AABB<P> where
P: Point,
impl<P: Eq> Eq for AABB<P> where
P: Point,
impl<P> StructuralEq for AABB<P> where
P: Point,
impl<P> StructuralPartialEq for AABB<P> where
P: Point,
Auto Trait Implementations
impl<P> RefUnwindSafe for AABB<P> where
P: RefUnwindSafe,
impl<P> Send for AABB<P> where
P: Send,
impl<P> Sync for AABB<P> where
P: Sync,
impl<P> Unpin for AABB<P> where
P: Unpin,
impl<P> UnwindSafe for AABB<P> where
P: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more