Struct rstar::AABB

source ·
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,

source

pub fn from_point(p: P) -> Self

Returns the AABB encompassing a single point.

source

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.

source

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.

source

pub fn from_corners(p1: P, p2: P) -> Self

Creates a new AABB encompassing two points.

source

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.

source

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.

source

pub fn distance_2(&self, point: &P) -> P::Scalar

Returns the squared distance to the AABB’s min_point

Trait Implementations§

source§

impl<P> Clone for AABB<P>where P: Point + Clone,

source§

fn clone(&self) -> AABB<P>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<P> Debug for AABB<P>where P: Point + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<P> Envelope for AABB<P>where P: Point,

§

type Point = P

The envelope’s point type.
source§

fn new_empty() -> Self

Creates a new, empty envelope that does not encompass any child.
source§

fn contains_point(&self, point: &P) -> bool

Returns true if a point is contained within this envelope.
source§

fn contains_envelope(&self, other: &Self) -> bool

Returns true if another envelope is fully contained within self.
source§

fn merge(&mut self, other: &Self)

Extends self to contain another envelope.
source§

fn merged(&self, other: &Self) -> Self

Returns the minimal envelope containing self and another envelope.
source§

fn intersects(&self, other: &Self) -> bool

Returns true if self and other intersect. The intersection might be of zero area (the two envelopes only touching each other).
source§

fn area(&self) -> P::Scalar

Returns this envelope’s area. Must be at least 0.
source§

fn distance_2(&self, point: &P) -> P::Scalar

Returns the euclidean distance to the envelope’s border.
source§

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
source§

fn center(&self) -> Self::Point

Returns the envelope’s center point.
source§

fn intersection_area(&self, other: &Self) -> <Self::Point as Point>::Scalar

Returns the area of the intersection of self and another envelope.
source§

fn perimeter_value(&self) -> P::Scalar

Returns a value proportional to the envelope’s perimeter.
source§

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

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
source§

impl<P> From<AABB<P>> for Rectangle<P>where P: Point,

source§

fn from(aabb: AABB<P>) -> Self

Converts to this type from the input type.
source§

impl<P> Ord for AABB<P>where P: Point + Ord,

source§

fn cmp(&self, other: &AABB<P>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl<P> PartialEq<AABB<P>> for AABB<P>where P: Point + PartialEq,

source§

fn eq(&self, other: &AABB<P>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<P> PartialOrd<AABB<P>> for AABB<P>where P: Point + PartialOrd,

source§

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 · source§

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 · source§

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
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<P> Copy for AABB<P>where P: Point + Copy,

source§

impl<P> Eq for AABB<P>where P: Point + Eq,

source§

impl<P> StructuralEq for AABB<P>where P: Point,

source§

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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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> ToOwned for Twhere T: Clone,

§

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

§

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

§

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.