[][src]Struct spade::BoundingRect

pub struct BoundingRect<V: PointN> { /* fields omitted */ }

An axis aligned minimal bounding rectangle.

An axis aligned minimal bounding rectangle is the smallest rectangle that completely surrounds an object and is aligned along all axes. The vector type V's dimension determines if this is a rectangle, a box or a higher dimensional volume.

Methods

impl<V> BoundingRect<V> where
    V: PointN
[src]

pub fn from_point(point: V) -> BoundingRect<V>[src]

Creates a bounding rectangle that contains exactly one point.

This will create a bounding rectangle with lower == upper == point.

pub fn from_points<I>(points: I) -> Self where
    I: IntoIterator<Item = V>, 
[src]

Create a bounding rectangle from a set of points

Panics

Panics if the given iterator is empty.

pub fn from_corners(corner1: &V, corner2: &V) -> BoundingRect<V>[src]

Creates a bounding rectangle that contains two points.

pub fn lower(&self) -> V[src]

Returns the lower corner of the bounding rectangle.

The lower corner has the smaller coordinates.

pub fn upper(&self) -> V[src]

Returns the upper corner of the bounding rectangle.

The upper corner has the larger coordinates.

pub fn contains_point(&self, point: &V) -> bool[src]

Checks if a point is contained within the bounding rectangle.

A point lying exactly on the bounding rectangle's border is also contained.

pub fn contains_rect(&self, rect: &BoundingRect<V>) -> bool[src]

Checks if another bounding rectangle is completley contained withing this rectangle.

A rectangle is contained if and only if all four corner are contained (see contains_point).

pub fn add_point(&mut self, point: V)[src]

Enlarges this bounding rectangle to contain a point.

If the point is already contained, nothing will be changed. Otherwise, this will enlarge self to be just large enough to contain the new point.

pub fn add_rect(&mut self, rect: &BoundingRect<V>)[src]

Enlarges this bounding rectangle to contain a rectangle.

If the rectangle is already contained, nothing will be changed. Otherwise, this will enlarge self to be just large enough to contain the new rectangle.

pub fn area(&self) -> V::Scalar[src]

Returns the rectangle's area.

pub fn half_margin(&self) -> V::Scalar[src]

Returns half of the rectangle's margin, thus width + height.

pub fn center(&self) -> V[src]

Returns the rectangle's center.

pub fn intersect(&self, other: &BoundingRect<V>) -> BoundingRect<V>[src]

Returns the intersection of this and another bounding rectangle.

If the rectangles do not intersect, a bounding rectangle with an area and margin of zero is returned.

pub fn intersects(&self, other: &BoundingRect<V>) -> bool[src]

Returns true if this and another bounding rectangle intersect each other. If the rectangles just "touch" each other at one side, true is returned.

Trait Implementations

impl<V> SpatialObject for BoundingRect<V> where
    V: PointN
[src]

type Point = V

The object's point type.

impl<V: Clone + PointN> Clone for BoundingRect<V>[src]

impl<V: PartialOrd + PointN> PartialOrd<BoundingRect<V>> for BoundingRect<V>[src]

impl<V: Copy + PointN> Copy for BoundingRect<V>[src]

impl<V: Eq + PointN> Eq for BoundingRect<V>[src]

impl<V: Ord + PointN> Ord for BoundingRect<V>[src]

impl<V: PartialEq + PointN> PartialEq<BoundingRect<V>> for BoundingRect<V>[src]

impl<V: Debug + PointN> Debug for BoundingRect<V>[src]

impl<V: Hash + PointN> Hash for BoundingRect<V>[src]

Auto Trait Implementations

impl<V> Sync for BoundingRect<V> where
    V: Sync

impl<V> Unpin for BoundingRect<V> where
    V: Unpin

impl<V> Send for BoundingRect<V> where
    V: Send

impl<V> UnwindSafe for BoundingRect<V> where
    V: UnwindSafe

impl<V> RefUnwindSafe for BoundingRect<V> where
    V: RefUnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Scalar for T where
    T: Copy + PartialEq<T> + Any + Debug
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>,