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]
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
.
fn from_corners(corner1: &V, corner2: &V) -> BoundingRect<V>
Creates a bounding rectangle that contains two points.
fn lower(&self) -> V
Returns the lower corner of the bounding rectangle.
The lower corner has the smaller coordinates.
fn upper(&self) -> V
Returns the upper corner of the bounding rectangle.
The upper corner has the larger coordinates.
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.
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
).
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.
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.
fn area(&self) -> V::Scalar
Returns the rectangle's area.
fn half_margin(&self) -> V::Scalar
Returns half of the rectangle's margin, thus width + height
.
fn center(&self) -> V
Returns the rectangle's center.
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.
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]
fn clone(&self) -> BoundingRect<V>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<V: PartialEq + PointN> PartialEq for BoundingRect<V>
[src]
fn eq(&self, __arg_0: &BoundingRect<V>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &BoundingRect<V>) -> bool
This method tests for !=
.