Struct spade::BoundingRect
source · pub struct BoundingRect<V: PointN> { /* private fields */ }
Expand description
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.
Implementations
sourceimpl<V> BoundingRect<V>where
V: PointN,
impl<V> BoundingRect<V>where
V: PointN,
sourcepub fn from_point(point: V) -> BoundingRect<V>
pub fn from_point(point: V) -> BoundingRect<V>
Creates a bounding rectangle that contains exactly one point.
This will create a bounding rectangle with lower == upper == point
.
sourcepub fn from_points<I>(points: I) -> Selfwhere
I: IntoIterator<Item = V>,
pub fn from_points<I>(points: I) -> Selfwhere
I: IntoIterator<Item = V>,
sourcepub fn from_corners(corner1: &V, corner2: &V) -> BoundingRect<V>
pub fn from_corners(corner1: &V, corner2: &V) -> BoundingRect<V>
Creates a bounding rectangle that contains two points.
sourcepub fn lower(&self) -> V
pub fn lower(&self) -> V
Returns the lower corner of the bounding rectangle.
The lower corner has the smaller coordinates.
sourcepub fn upper(&self) -> V
pub fn upper(&self) -> V
Returns the upper corner of the bounding rectangle.
The upper corner has the larger coordinates.
sourcepub fn contains_point(&self, point: &V) -> bool
pub fn contains_point(&self, point: &V) -> bool
Checks if a point is contained within the bounding rectangle.
A point lying exactly on the bounding rectangle’s border is also contained.
sourcepub fn contains_rect(&self, rect: &BoundingRect<V>) -> bool
pub fn contains_rect(&self, rect: &BoundingRect<V>) -> bool
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
).
sourcepub fn add_point(&mut self, point: V)
pub fn add_point(&mut self, point: V)
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.
sourcepub fn add_rect(&mut self, rect: &BoundingRect<V>)
pub fn add_rect(&mut self, rect: &BoundingRect<V>)
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.
sourcepub fn half_margin(&self) -> V::Scalar
pub fn half_margin(&self) -> V::Scalar
Returns half of the rectangle’s margin, thus width + height
.
sourcepub fn intersect(&self, other: &BoundingRect<V>) -> BoundingRect<V>
pub fn intersect(&self, other: &BoundingRect<V>) -> BoundingRect<V>
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.
sourcepub fn intersects(&self, other: &BoundingRect<V>) -> bool
pub fn intersects(&self, other: &BoundingRect<V>) -> bool
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
sourceimpl<V: Clone + PointN> Clone for BoundingRect<V>
impl<V: Clone + PointN> Clone for BoundingRect<V>
sourcefn clone(&self) -> BoundingRect<V>
fn clone(&self) -> BoundingRect<V>
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl<V: Debug + PointN> Debug for BoundingRect<V>
impl<V: Debug + PointN> Debug for BoundingRect<V>
sourceimpl<V: Hash + PointN> Hash for BoundingRect<V>
impl<V: Hash + PointN> Hash for BoundingRect<V>
sourceimpl<V: Ord + PointN> Ord for BoundingRect<V>
impl<V: Ord + PointN> Ord for BoundingRect<V>
sourcefn cmp(&self, other: &BoundingRect<V>) -> Ordering
fn cmp(&self, other: &BoundingRect<V>) -> Ordering
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
sourceimpl<V: PartialEq + PointN> PartialEq<BoundingRect<V>> for BoundingRect<V>
impl<V: PartialEq + PointN> PartialEq<BoundingRect<V>> for BoundingRect<V>
sourcefn eq(&self, other: &BoundingRect<V>) -> bool
fn eq(&self, other: &BoundingRect<V>) -> bool
sourceimpl<V: PartialOrd + PointN> PartialOrd<BoundingRect<V>> for BoundingRect<V>
impl<V: PartialOrd + PointN> PartialOrd<BoundingRect<V>> for BoundingRect<V>
sourcefn partial_cmp(&self, other: &BoundingRect<V>) -> Option<Ordering>
fn partial_cmp(&self, other: &BoundingRect<V>) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresourceimpl<V> SpatialObject for BoundingRect<V>where
V: PointN,
impl<V> SpatialObject for BoundingRect<V>where
V: PointN,
type Point = V
type Point = V
sourcefn mbr(&self) -> BoundingRect<V>
fn mbr(&self) -> BoundingRect<V>
impl<V: Copy + PointN> Copy for BoundingRect<V>
impl<V: Eq + PointN> Eq for BoundingRect<V>
impl<V: PointN> StructuralEq for BoundingRect<V>
impl<V: PointN> StructuralPartialEq for BoundingRect<V>
Auto Trait Implementations
impl<V> RefUnwindSafe for BoundingRect<V>where
V: RefUnwindSafe,
impl<V> Send for BoundingRect<V>where
V: Send,
impl<V> Sync for BoundingRect<V>where
V: Sync,
impl<V> Unpin for BoundingRect<V>where
V: Unpin,
impl<V> UnwindSafe for BoundingRect<V>where
V: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read morefn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.