Struct spade::BoundingRect [−][src]
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]
impl<V> BoundingRect<V> where
V: PointN,
pub fn from_point(point: V) -> BoundingRect<V>
[src]
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
.
pub fn from_points<I>(points: I) -> Self where
I: IntoIterator<Item = V>,
[src]
pub fn from_points<I>(points: I) -> Self where
I: IntoIterator<Item = V>,
pub fn from_corners(corner1: &V, corner2: &V) -> BoundingRect<V>
[src]
pub fn from_corners(corner1: &V, corner2: &V) -> BoundingRect<V>
Creates a bounding rectangle that contains two points.
pub fn lower(&self) -> V
[src]
pub fn lower(&self) -> V
Returns the lower corner of the bounding rectangle.
The lower corner has the smaller coordinates.
pub fn upper(&self) -> V
[src]
pub fn upper(&self) -> V
Returns the upper corner of the bounding rectangle.
The upper corner has the larger coordinates.
pub fn contains_point(&self, point: &V) -> bool
[src]
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.
pub fn contains_rect(&self, rect: &BoundingRect<V>) -> bool
[src]
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
).
pub fn add_point(&mut self, point: V)
[src]
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.
pub fn add_rect(&mut self, rect: &BoundingRect<V>)
[src]
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.
pub fn area(&self) -> V::Scalar
[src]
pub fn area(&self) -> V::Scalar
Returns the rectangle's area.
pub fn half_margin(&self) -> V::Scalar
[src]
pub fn half_margin(&self) -> V::Scalar
Returns half of the rectangle's margin, thus width + height
.
pub fn center(&self) -> V
[src]
pub fn center(&self) -> V
Returns the rectangle's center.
pub fn intersect(&self, other: &BoundingRect<V>) -> BoundingRect<V>
[src]
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.
pub fn intersects(&self, other: &BoundingRect<V>) -> bool
[src]
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
impl<V: Clone + PointN> Clone for BoundingRect<V>
[src]
impl<V: Clone + PointN> Clone for BoundingRect<V>
fn clone(&self) -> BoundingRect<V>
[src]
fn clone(&self) -> BoundingRect<V>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<V: PartialEq + PointN> PartialEq for BoundingRect<V>
[src]
impl<V: PartialEq + PointN> PartialEq for BoundingRect<V>
fn eq(&self, other: &BoundingRect<V>) -> bool
[src]
fn eq(&self, other: &BoundingRect<V>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &BoundingRect<V>) -> bool
[src]
fn ne(&self, other: &BoundingRect<V>) -> bool
This method tests for !=
.
impl<V: Debug + PointN> Debug for BoundingRect<V>
[src]
impl<V: Debug + PointN> Debug for BoundingRect<V>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<V> SpatialObject for BoundingRect<V> where
V: PointN,
[src]
impl<V> SpatialObject for BoundingRect<V> where
V: PointN,
type Point = V
The object's point type.
fn mbr(&self) -> BoundingRect<V>
[src]
fn mbr(&self) -> BoundingRect<V>
Returns the object's minimal bounding rectangle. Read more
fn distance2(&self, point: &Self::Point) -> V::Scalar
[src]
fn distance2(&self, point: &Self::Point) -> V::Scalar
Returns the squared euclidean distance from the object's contour. Returns a value samller than zero if the point is contained within the object. Read more
fn contains(&self, point: &Self::Point) -> bool
[src]
fn contains(&self, point: &Self::Point) -> bool
Returns true if a given point is contained in this object.
Auto Trait Implementations
impl<V> Send for BoundingRect<V> where
V: Send,
impl<V> Send for BoundingRect<V> where
V: Send,
impl<V> Sync for BoundingRect<V> where
V: Sync,
impl<V> Sync for BoundingRect<V> where
V: Sync,