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§
Source§impl<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) -> Selfwhere
I: IntoIterator<Item = &'a P> + 'a,
P: 'a,
pub fn from_points<'a, I>(i: I) -> Selfwhere
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§
Source§impl<P> Envelope for AABB<P>where
P: Point,
impl<P> Envelope for AABB<P>where
P: Point,
Source§fn contains_point(&self, point: &P) -> bool
fn contains_point(&self, point: &P) -> bool
Source§fn contains_envelope(&self, other: &Self) -> bool
fn contains_envelope(&self, other: &Self) -> bool
self
.Source§fn merged(&self, other: &Self) -> Self
fn merged(&self, other: &Self) -> Self
self
and another envelope.Source§fn intersects(&self, other: &Self) -> bool
fn intersects(&self, other: &Self) -> bool
self
and other
intersect. The intersection might be
of zero area (the two envelopes only touching each other).Source§fn distance_2(&self, point: &P) -> P::Scalar
fn distance_2(&self, point: &P) -> P::Scalar
Source§fn min_max_dist_2(&self, point: &P) -> <P as Point>::Scalar
fn min_max_dist_2(&self, point: &P) -> <P as Point>::Scalar
Source§fn intersection_area(&self, other: &Self) -> <Self::Point as Point>::Scalar
fn intersection_area(&self, other: &Self) -> <Self::Point as Point>::Scalar
self
and another envelope.