RotatedRect

Struct RotatedRect 

Source
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

Source

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.

Source

pub fn contains(&self, point: PointF) -> bool

Return true if a point lies within this rotated rect.

Source

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.

Source

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].

Source

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.

Source

pub fn center(&self) -> PointF

Return the centroid of the rect.

Source

pub fn up_axis(&self) -> Vec2

Return the normalized vector that indicates the “up” direction for this rect.

Source

pub fn width(&self) -> f32

Return the extent of the rect along the axis perpendicular to self.up_axis().

Source

pub fn height(&self) -> f32

Return the extent of the rect along self.up_axis().

Source

pub fn area(&self) -> f32

Return the signed area of this rect.

Source

pub fn resize(&mut self, width: f32, height: f32)

Set the extents of this rect. width and height must be >= 0.

Source

pub fn intersects(&self, other: &RotatedRect) -> bool

Return true if the intersection of this rect and other is non-empty.

Source

pub fn from_rect(r: RectF) -> RotatedRect

Return a new axis-aligned RotatedRect whose bounding rectangle matches r.

Source

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

Source§

type Coord = f32

Coordinate type of bounding rect.
Source§

fn bounding_rect(&self) -> RectF

Return the smallest axis-aligned bounding rect which contains this shape.
Source§

impl Clone for RotatedRect

Source§

fn clone(&self) -> RotatedRect

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RotatedRect

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for RotatedRect

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.