pub struct RotatedRect { /* private fields */ }Expand description
An oriented rectangle.
This is characterized by a center point, an “up” direction indicating the orientation, width (extent along axis perpendicular to the up axis) and height (extent along up axis).
Implementations§
Source§impl RotatedRect
impl RotatedRect
Sourcepub fn new(
center: PointF,
up_axis: Vec2,
width: f32,
height: f32,
) -> RotatedRect
pub fn new( center: PointF, up_axis: Vec2, width: f32, height: f32, ) -> RotatedRect
Construct a new RotatedRect with a given center, up direction and
dimensions.
Sourcepub fn contains(&self, point: PointF) -> bool
pub fn contains(&self, point: PointF) -> bool
Return true if a point lies within this rotated rect.
Sourcepub fn expanded(&self, dw: f32, dh: f32) -> RotatedRect
pub fn expanded(&self, dw: f32, dh: f32) -> RotatedRect
Return a copy of this rect with width increased by dw and height
increased by dh.
Sourcepub fn corners(&self) -> [PointF; 4]
pub fn corners(&self) -> [PointF; 4]
Return the coordinates of the rect’s corners.
The corners are returned in clockwise order starting from the corner that is the top-left when the “up” axis has XY coordinates [0, 1], or equivalently, bottom-right when the “up” axis has XY coords [0, -1].
Sourcepub fn edges(&self) -> [LineF; 4]
pub fn edges(&self) -> [LineF; 4]
Return the edges of this rect, in clockwise order starting from the edge that is the top edge if the rect has no rotation.
Sourcepub fn up_axis(&self) -> Vec2
pub fn up_axis(&self) -> Vec2
Return the normalized vector that indicates the “up” direction for this rect.
Sourcepub fn width(&self) -> f32
pub fn width(&self) -> f32
Return the extent of the rect along the axis perpendicular to self.up_axis().
Sourcepub fn resize(&mut self, width: f32, height: f32)
pub fn resize(&mut self, width: f32, height: f32)
Set the extents of this rect. width and height must be >= 0.
Sourcepub fn intersects(&self, other: &RotatedRect) -> bool
pub fn intersects(&self, other: &RotatedRect) -> bool
Return true if the intersection of this rect and other is non-empty.
Sourcepub fn from_rect(r: RectF) -> RotatedRect
pub fn from_rect(r: RectF) -> RotatedRect
Return a new axis-aligned RotatedRect whose bounding rectangle matches
r.
Sourcepub fn orient_towards(&self, up: Vec2) -> RotatedRect
pub fn orient_towards(&self, up: Vec2) -> RotatedRect
Return the rectangle with the same corner points as self, but with
an up axis that has a direction as close to up as possible.
Trait Implementations§
Source§impl BoundingRect for RotatedRect
impl BoundingRect for RotatedRect
Source§impl Clone for RotatedRect
impl Clone for RotatedRect
Source§fn clone(&self) -> RotatedRect
fn clone(&self) -> RotatedRect
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RotatedRect
impl Debug for RotatedRect
impl Copy for RotatedRect
Auto Trait Implementations§
impl Freeze for RotatedRect
impl RefUnwindSafe for RotatedRect
impl Send for RotatedRect
impl Sync for RotatedRect
impl Unpin for RotatedRect
impl UnwindSafe for RotatedRect
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