#[repr(C)]pub struct Box2D<T> {
pub min: Point<T>,
pub max: Point<T>,
}Expand description
A 2d axis aligned rectangle represented by its minimum and maximum coordinates.
§Representation
This struct is similar to Rect, but stores rectangle as two endpoints
instead of origin point and size. Such representation has several advantages over
Rect representation:
- Several operations are more efficient with
Box2D, includingintersection,union, and point-in-rect. - The representation is less susceptible to overflow. With
Rect, computation of second point can overflow for a large range of values of origin and size. However, withBox2D, computation ofsizecannot overflow if the coordinates are signed and the resulting size is unsigned.
A known disadvantage of Box2D is that translating the rectangle requires translating
both points, whereas translating Rect only requires translating one point.
§Empty box
A box is considered empty (see is_empty) if any of the following is true:
- it’s area is empty,
- it’s area is negative (
min.x > max.xormin.y > max.y), - it contains NaNs.
Fields§
§min: Point<T>Represents min point
max: Point<T>Represents max point
Auto Trait Implementations§
impl<T> Freeze for Box2D<T>where
T: Freeze,
impl<T> RefUnwindSafe for Box2D<T>where
T: RefUnwindSafe,
impl<T> Send for Box2D<T>where
T: Send,
impl<T> Sync for Box2D<T>where
T: Sync,
impl<T> Unpin for Box2D<T>where
T: Unpin,
impl<T> UnwindSafe for Box2D<T>where
T: UnwindSafe,
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<Fr, To> IntoColor<To> for Frwhere
To: FromColor<Fr>,
impl<Fr, To> IntoColor<To> for Frwhere
To: FromColor<Fr>,
Source§fn into_color(self) -> To
fn into_color(self) -> To
Convert into color