pub struct Rectangle2 {
pub origin: DVec2,
pub x: DVec2,
pub y: DVec2,
}Expand description
A rectangle in the XY-plane, possibly rotated.
Stored as a corner and two edge vectors so the parallelogram property holds
by construction, matching Rectangle3. Perpendicularity is not enforced:
a sheared import stays representable and inspectable.
Fields§
§origin: DVec2Corner the edge vectors start from.
x: DVec2First edge vector, from origin.
y: DVec2Second edge vector, from origin.
Implementations§
Source§impl Rectangle2
impl Rectangle2
Sourcepub const fn new(origin: DVec2, x: DVec2, y: DVec2) -> Rectangle2
pub const fn new(origin: DVec2, x: DVec2, y: DVec2) -> Rectangle2
Construct from a corner and two edge vectors.
Sourcepub fn from_aabb(bounds: &Aabb2) -> Option<Rectangle2>
pub fn from_aabb(bounds: &Aabb2) -> Option<Rectangle2>
An axis-aligned rectangle spanning bounds.
Returns None for an empty box, because an inverted corner pair has no
meaningful edge vectors and silently producing a zero-sized rectangle
at the origin would hide the emptiness from the caller.
Sourcepub fn signed_area(&self) -> f64
pub fn signed_area(&self) -> f64
Signed area: positive when the edge vectors are counter-clockwise.
Trait Implementations§
Source§impl Clone for Rectangle2
impl Clone for Rectangle2
Source§fn clone(&self) -> Rectangle2
fn clone(&self) -> Rectangle2
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Rectangle2
impl Debug for Rectangle2
Source§impl PartialEq for Rectangle2
impl PartialEq for Rectangle2
impl Copy for Rectangle2
impl StructuralPartialEq for Rectangle2
Auto Trait Implementations§
impl Freeze for Rectangle2
impl RefUnwindSafe for Rectangle2
impl Send for Rectangle2
impl Sync for Rectangle2
impl Unpin for Rectangle2
impl UnwindSafe for Rectangle2
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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