pub struct AARectangle {
pub x_min: fsize,
pub y_min: fsize,
pub x_max: fsize,
pub y_max: fsize,
}
Expand description
Geometric primitive representing an axis-aligned rectangle
Fields§
§x_min: fsize
§y_min: fsize
§x_max: fsize
§y_max: fsize
Implementations§
Source§impl AARectangle
impl AARectangle
Sourcepub const QUADRANT_NEIGHBOR_LAYOUT: [[usize; 2]; 4]
pub const QUADRANT_NEIGHBOR_LAYOUT: [[usize; 2]; 4]
For all quadrants, contains indices of the two neighbors of the quadrant at that index.
pub fn new(x_min: fsize, y_min: fsize, x_max: fsize, y_max: fsize) -> Self
Sourcepub fn relation_to(&self, other: &AARectangle) -> GeoRelation
pub fn relation_to(&self, other: &AARectangle) -> GeoRelation
Returns the relation between self and another AARectangle
Sourcepub fn almost_relation_to(&self, other: &AARectangle) -> GeoRelation
pub fn almost_relation_to(&self, other: &AARectangle) -> GeoRelation
Returns the relation between self and another AARectangle, with a tolerance for floating point precision.
Leaning towards Surrounding
and Enclosed
instead of Intersecting
in edge cases.
Sourcepub fn inflate_to_square(&self) -> AARectangle
pub fn inflate_to_square(&self) -> AARectangle
Returns the rectangle that is the result of inflating the smallest dimension of the rectangle to match the largest dimension
pub fn scale(self, factor: fsize) -> Self
Sourcepub fn resize_by(self, dx: fsize, dy: fsize) -> Option<Self>
pub fn resize_by(self, dx: fsize, dy: fsize) -> Option<Self>
Returns a new rectangle with the same center but expanded by dx
in both x-directions and by dy
in both y-directions.
If the new rectangle is invalid (x_min >= x_max or y_min >= y_max), returns None.
Sourcepub fn quadrants(&self) -> [Self; 4]
pub fn quadrants(&self) -> [Self; 4]
Returns the 4 quadrants of the rectangle. Ordered in the same way as quadrants in a cartesian plane: https://en.wikipedia.org/wiki/Quadrant_(plane_geometry)
Sourcepub fn corners(&self) -> [Point; 4]
pub fn corners(&self) -> [Point; 4]
Returns the four corners, in the same order as AARectangle::quadrants.
Sourcepub fn edges(&self) -> [Edge; 4]
pub fn edges(&self) -> [Edge; 4]
Returns the four edges of the rectangle, in the same order as AARectangle::quadrants.
pub fn width(&self) -> fsize
pub fn height(&self) -> fsize
pub fn from_intersection( a: &AARectangle, b: &AARectangle, ) -> Option<AARectangle>
pub fn bounding_rectangle(a: &AARectangle, b: &AARectangle) -> AARectangle
Trait Implementations§
Source§impl AlmostCollidesWith<AARectangle> for AARectangle
impl AlmostCollidesWith<AARectangle> for AARectangle
fn almost_collides_with(&self, other: &AARectangle) -> bool
Source§impl AlmostCollidesWith<Point> for AARectangle
impl AlmostCollidesWith<Point> for AARectangle
fn almost_collides_with(&self, point: &Point) -> bool
Source§impl Clone for AARectangle
impl Clone for AARectangle
Source§fn clone(&self) -> AARectangle
fn clone(&self) -> AARectangle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl CollidesWith<AARectangle> for AARectangle
impl CollidesWith<AARectangle> for AARectangle
fn collides_with(&self, other: &AARectangle) -> bool
Source§impl CollidesWith<AARectangle> for Circle
impl CollidesWith<AARectangle> for Circle
fn collides_with(&self, rect: &AARectangle) -> bool
Source§impl CollidesWith<AARectangle> for Edge
impl CollidesWith<AARectangle> for Edge
fn collides_with(&self, other: &AARectangle) -> bool
Source§impl CollidesWith<Edge> for AARectangle
impl CollidesWith<Edge> for AARectangle
fn collides_with(&self, edge: &Edge) -> bool
Source§impl CollidesWith<Point> for AARectangle
impl CollidesWith<Point> for AARectangle
fn collides_with(&self, point: &Point) -> bool
Source§impl Debug for AARectangle
impl Debug for AARectangle
Source§impl Distance<Point> for AARectangle
impl Distance<Point> for AARectangle
Source§impl PartialEq for AARectangle
impl PartialEq for AARectangle
Source§impl SeparationDistance<Point> for AARectangle
impl SeparationDistance<Point> for AARectangle
Source§fn separation_distance(&self, point: &Point) -> (GeoPosition, fsize)
fn separation_distance(&self, point: &Point) -> (GeoPosition, fsize)
self
and other
, returns GeoPosition::Interior and the minimum distance to separate the two primitives.
Otherwise, returns GeoPosition::Exterior and the minimum distance between the two primitives. (similar to Distance::distance)Source§fn sq_separation_distance(&self, point: &Point) -> (GeoPosition, fsize)
fn sq_separation_distance(&self, point: &Point) -> (GeoPosition, fsize)
Source§impl Shape for AARectangle
impl Shape for AARectangle
impl QTQueryable for AARectangle
impl StructuralPartialEq for AARectangle
Auto Trait Implementations§
impl Freeze for AARectangle
impl RefUnwindSafe for AARectangle
impl Send for AARectangle
impl Sync for AARectangle
impl Unpin for AARectangle
impl UnwindSafe for AARectangle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more