[][src]Struct rustbatch::math::rect::Rect

pub struct Rect {
    pub min: Vect,
    pub max: Vect,
}

Rect is Rectangular shape or AABB for detecting collisions in 2D space

Fields

min: Vectmax: Vect

Implementations

impl Rect[src]

pub const ZERO: Rect[src]

pub const INVERTED_MAX_RECT: Rect[src]

pub const MAX_RECT: Rect[src]

pub fn new(x0: f32, y0: f32, x1: f32, y1: f32) -> Rect[src]

new is rect constructor

pub fn wh(x: f32, y: f32, w: f32, h: f32) -> Rect[src]

wn lets you specify width and height of rectangle rather then two points

pub fn centered(c: Vect, w: f32, h: f32) -> Rect[src]

centered returns rect that has center in c

pub fn cube(c: Vect, rad: f32) -> Rect[src]

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

pub fn from_vec(v: Vect) -> Rect[src]

from_vec turns vector to rectangle. This works properly only for purely positive otherwise normalization is required

pub fn bounds_for(points: &[Vect]) -> Rect[src]

bounds for returns rectangle where all points from slice fits in

pub fn verts(&self) -> [Vect; 4][src]

verts returns corner points of rectangle

pub fn union(&self, o: &Rect) -> Rect[src]

union returns smallest rectangle in witch both self and o fits in

pub fn center(&self) -> Vect[src]

center returns center of rectangle

pub fn loc_verts(&self) -> [Vect; 4][src]

loc_verts returns corners of rectangle relative to its center

pub fn to_local(&self) -> Rect[src]

to_local returns rect centered around coordinate origin (0, 0)

pub fn width(&self) -> f32[src]

width returns rectangles width

pub fn height(&self) -> f32[src]

height returns rectangles height

pub fn respective(&self, pos: Vect) -> Sides[src]

respective returns where the point is respective to rectangle

pub fn normalized(self) -> Rect[src]

normalized normalizes rectangle so the min is lower them max

pub fn contains(&self, pos: Vect) -> bool[src]

contains returns whether rect contains the points

pub fn fits_in(&self, o: &Rect) -> bool[src]

fits_in returns whether self fits in o

pub fn radius(&self) -> f32[src]

radius returns distance from rect center to max

pub fn moved(&self, delta: Vect) -> Self[src]

moved returns rectangle moved by delta

pub fn centered_to(&self, pos: Vect) -> Self[src]

pub fn area(&self) -> f32[src]

pub fn to_rays(&self) -> [Ray; 4][src]

Trait Implementations

impl Clone for Rect[src]

impl Copy for Rect[src]

impl Debug for Rect[src]

impl Default for Rect[src]

impl Intersection<Circ> for Rect[src]

fn intersects(&self, o: &Circ) -> bool[src]

returns whether rectangle intersects circle

impl Intersection<Ray> for Rect[src]

fn intersects(&self, o: &Ray) -> bool[src]

returns whether rectangle intersects ray

impl Intersection<Rect> for Rect[src]

fn intersects(&self, o: &Rect) -> bool[src]

returns whether rectangle intersects another rectangle

impl Intersection<Rect> for Circ[src]

impl Intersection<Rect> for Ray[src]

impl IntersectionPoints<Ray> for Rect[src]

fn intersects_points(&self, o: &Ray) -> [Option<Vect>; 2][src]

returns intersection points of rectangle and ray

impl IntersectionPoints<Rect> for Ray[src]

Auto Trait Implementations

impl RefUnwindSafe for Rect

impl Send for Rect

impl Sync for Rect

impl Unpin for Rect

impl UnwindSafe for Rect

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,