pub struct Rectangle2 {
pub origin: Point2,
pub x: Vec2,
pub y: Vec2,
}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: Point2Corner the edge vectors start from.
x: Vec2First edge vector, from origin.
y: Vec2Second edge vector, from origin.
Implementations§
Source§impl Rectangle2
impl Rectangle2
Sourcepub const fn new(origin: Point2, x: Vec2, y: Vec2) -> Self
pub const fn new(origin: Point2, x: Vec2, y: Vec2) -> Self
Construct from a corner and two edge vectors.
Sourcepub fn from_aabb(bounds: &Aabb2) -> Option<Self>
pub fn from_aabb(bounds: &Aabb2) -> Option<Self>
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) -> Scalar
pub fn signed_area(&self) -> Scalar
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