Struct rstar::primitives::Rectangle

source ·
pub struct Rectangle<P>where
    P: Point,{ /* private fields */ }
Expand description

An n-dimensional rectangle defined by its two corners.

This rectangle can be directly inserted into an r-tree.

Note: Despite being called rectangle, this struct can be used with more than two dimensions by using an appropriate point type.

Type parameters

P: The rectangle’s Point type.

Implementations§

source§

impl<P> Rectangle<P>where P: Point,

source

pub fn from_corners(corner_1: P, corner_2: P) -> Self

Creates a new rectangle defined by two corners.

source

pub fn from_aabb(aabb: AABB<P>) -> Self

Creates a new rectangle defined by it’s [axis aligned bounding box(AABB).

source

pub fn lower(&self) -> P

Returns the rectangle’s lower corner.

This is the point contained within the rectangle with the smallest coordinate value in each dimension.

source

pub fn upper(&self) -> P

Returns the rectangle’s upper corner.

This is the point contained within the AABB with the largest coordinate value in each dimension.

source§

impl<P> Rectangle<P>where P: Point,

source

pub fn nearest_point(&self, query_point: &P) -> P

Returns the nearest point within this rectangle to a given point.

If query_point is contained within this rectangle, query_point is returned.

Trait Implementations§

source§

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

source§

fn clone(&self) -> Rectangle<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 Rectangle<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> 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 Rectangle<P>where P: Point + Ord,

source§

fn cmp(&self, other: &Rectangle<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<Rectangle<P>> for Rectangle<P>where P: Point + PartialEq,

source§

fn eq(&self, other: &Rectangle<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<Rectangle<P>> for Rectangle<P>where P: Point + PartialOrd,

source§

fn partial_cmp(&self, other: &Rectangle<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> PointDistance for Rectangle<P>where P: Point,

source§

fn distance_2( &self, point: &<Self::Envelope as Envelope>::Point ) -> <<Self::Envelope as Envelope>::Point as Point>::Scalar

Returns the squared euclidean distance between an object to a point.
source§

fn contains_point(&self, point: &<Self::Envelope as Envelope>::Point) -> bool

Returns true if a point is contained within this object. Read more
source§

fn distance_2_if_less_or_equal( &self, point: &<Self::Envelope as Envelope>::Point, max_distance_2: <<Self::Envelope as Envelope>::Point as Point>::Scalar ) -> Option<<<Self::Envelope as Envelope>::Point as Point>::Scalar>

Returns the squared distance to this object, or None if the distance is larger than a given maximum value. Read more
source§

impl<P> RTreeObject for Rectangle<P>where P: Point,

§

type Envelope = AABB<P>

The object’s envelope type. Usually, AABB will be the right choice. This type also defines the object’s dimensionality.
source§

fn envelope(&self) -> Self::Envelope

Returns the object’s envelope. Read more
source§

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

source§

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

source§

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

source§

impl<P> StructuralPartialEq for Rectangle<P>where P: Point,

Auto Trait Implementations§

§

impl<P> RefUnwindSafe for Rectangle<P>where P: RefUnwindSafe,

§

impl<P> Send for Rectangle<P>where P: Send,

§

impl<P> Sync for Rectangle<P>where P: Sync,

§

impl<P> Unpin for Rectangle<P>where P: Unpin,

§

impl<P> UnwindSafe for Rectangle<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.