Skip to main content

Rect

Struct Rect 

Source
pub struct Rect { /* private fields */ }
Expand description

A 2D axis-aligned bounding rectangle.

Wraps the manifold3d Rect type, providing spatial queries (containment, overlap), combining operations (union, expand), and transforms.

Obtain a Rect from CrossSection::bounds, or construct one directly from min/max coordinates.

Implementations§

Source§

impl Rect

Source

pub fn new(min: [f64; 2], max: [f64; 2]) -> Self

Create a rectangle from min and max corners.

Source

pub fn min(&self) -> [f64; 2]

Minimum corner [x, y].

Source

pub fn max(&self) -> [f64; 2]

Maximum corner [x, y].

Source

pub fn dimensions(&self) -> [f64; 2]

Dimensions [width, height].

Source

pub fn center(&self) -> [f64; 2]

Center point [x, y].

Source

pub fn scale(&self) -> f64

The maximum distance from the center to any corner (half-diagonal).

Source

pub fn is_empty(&self) -> bool

Whether the rectangle is empty (zero area).

Source

pub fn is_finite(&self) -> bool

Whether the rectangle has finite (non-infinite, non-NaN) bounds.

Source

pub fn contains_point(&self, point: [f64; 2]) -> bool

Whether the rectangle fully contains the given point.

Source

pub fn contains_rect(&self, other: &Rect) -> bool

Whether the rectangle fully contains another rectangle.

Source

pub fn overlaps_rect(&self, other: &Rect) -> bool

Whether this rectangle overlaps with another rectangle.

Source

pub fn include_point(&mut self, point: [f64; 2])

Expand this rectangle to include the given point.

Source

pub fn union(&self, other: &Rect) -> Rect

Return the union (smallest rectangle containing both) of two rectangles.

Source

pub fn transform(&self, m: &[f64; 6]) -> Rect

Apply a 3x2 affine transformation matrix (column-major).

Layout: [x1, y1, x2, y2, x3, y3] where columns are:

  • col1 (x1,y1) — X basis vector
  • col2 (x2,y2) — Y basis vector
  • col3 (x3,y3) — translation
Source

pub fn translate(&self, v: [f64; 2]) -> Rect

Translate the rectangle by [x, y].

Source

pub fn mul(&self, v: [f64; 2]) -> Rect

Scale the rectangle by [x, y] factors.

Trait Implementations§

Source§

impl Clone for Rect

Source§

fn clone(&self) -> Self

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 Rect

Source§

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

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

impl Drop for Rect

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Rect

Source§

impl Sync for Rect

Auto Trait Implementations§

§

impl Freeze for Rect

§

impl RefUnwindSafe for Rect

§

impl Unpin for Rect

§

impl UnsafeUnpin for Rect

§

impl UnwindSafe for Rect

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.