pub struct Rect {
pub min: Vect,
pub max: Vect,
}
Expand description
Rect is Rectangular shape or AABB for detecting collisions in 2D space
Fields§
§min: Vect
§max: Vect
Implementations§
Source§impl Rect
impl Rect
pub const ZERO: Rect
pub const INVERTED_MAX_RECT: Rect
pub const MAX_RECT: Rect
Sourcepub fn wh(x: f32, y: f32, w: f32, h: f32) -> Rect
pub fn wh(x: f32, y: f32, w: f32, h: f32) -> Rect
wn lets you specify width and height of rectangle rather then two points
Sourcepub fn cube(c: Vect, rad: f32) -> Rect
pub fn cube(c: Vect, rad: f32) -> Rect
cube is similar to centered but you specify just radius of cube with means that if rad is 5 then width and height are 10
Sourcepub fn from_vec(v: Vect) -> Rect
pub fn from_vec(v: Vect) -> Rect
from_vec turns vector to rectangle. This works properly only for purely positive otherwise normalization is required
Sourcepub fn bounds_for(points: &[Vect]) -> Rect
pub fn bounds_for(points: &[Vect]) -> Rect
bounds for returns rectangle where all points from slice fits in
Sourcepub fn union(&self, o: &Rect) -> Rect
pub fn union(&self, o: &Rect) -> Rect
union returns smallest rectangle in witch both self and o fits in
Sourcepub fn loc_verts(&self) -> [Vect; 4]
pub fn loc_verts(&self) -> [Vect; 4]
loc_verts returns corners of rectangle relative to its center
Sourcepub fn respective(&self, pos: Vect) -> Sides
pub fn respective(&self, pos: Vect) -> Sides
respective returns where the point is respective to rectangle
Sourcepub fn normalized(self) -> Rect
pub fn normalized(self) -> Rect
normalized normalizes rectangle so the min is lower them max
pub fn centered_to(&self, pos: Vect) -> Self
pub fn area(&self) -> f32
pub fn to_rays(&self) -> [Ray; 4]
Trait Implementations§
Source§impl Intersection<Circ> for Rect
impl Intersection<Circ> for Rect
Source§fn intersects(&self, o: &Circ) -> bool
fn intersects(&self, o: &Circ) -> bool
returns whether rectangle intersects circle
Source§impl Intersection<Ray> for Rect
impl Intersection<Ray> for Rect
Source§fn intersects(&self, o: &Ray) -> bool
fn intersects(&self, o: &Ray) -> bool
returns whether rectangle intersects ray
Source§impl Intersection<Rect> for Circ
impl Intersection<Rect> for Circ
fn intersects(&self, o: &Rect) -> bool
Source§impl Intersection<Rect> for Ray
impl Intersection<Rect> for Ray
fn intersects(&self, o: &Rect) -> bool
Source§impl Intersection<Rect> for Rect
impl Intersection<Rect> for Rect
Source§fn intersects(&self, o: &Rect) -> bool
fn intersects(&self, o: &Rect) -> bool
returns whether rectangle intersects another rectangle
Source§impl IntersectionPoints<Ray> for Rect
impl IntersectionPoints<Ray> for Rect
Source§impl IntersectionPoints<Rect> for Ray
impl IntersectionPoints<Rect> for Ray
impl Copy for Rect
Auto Trait Implementations§
impl Freeze for Rect
impl RefUnwindSafe for Rect
impl Send for Rect
impl Sync for Rect
impl Unpin for Rect
impl UnwindSafe for Rect
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