[][src]Struct rustbatch::math::vect::Vect

pub struct Vect {
    pub x: f32,
    pub y: f32,
}

Vect is 2D vector and is used all over the place. I choose to use f32 because opengl also accepts only f32

Fields

x: f32y: f32

Implementations

impl Vect[src]

pub const ZERO: Self[src]

pub const LEFT: Self[src]

pub const RIGHT: Self[src]

pub const UP: Self[src]

pub const DOWN: Self[src]

pub const MAX: Self[src]

pub const MIN: Self[src]

pub fn average(arr: &[Vect]) -> Self[src]

average returns average of slice of vectors

pub fn new(x: f32, y: f32) -> Self[src]

new is vector constructor

pub fn mirror(m: f32) -> Self[src]

mirror returns homogenous vector

pub fn unit(a: f32) -> Self[src]

unit returns vector of length 1.0 with given angle

pub fn rad(a: f32, l: f32) -> Self[src]

rad is same as unit but you can also specify length

pub fn clamped(&self, min: f32, max: f32) -> Self[src]

clamped clamps a vectors length

pub fn lerp(self, o: Vect, t: f32) -> Vect[src]

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

ang returns vectors angle

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

len returns vectors length

pub fn norm(self) -> Self[src]

norm returns normalized vector with length 1.0

pub fn normal(&self) -> Self[src]

normal on the other hand returns normal vector to vector of same length

pub fn swp(self) -> Self[src]

swp swaps x and y of vector

pub fn rot(self, a: f32) -> Self[src]

rot rotates vector by a

pub fn dist(self, b: Self) -> f32[src]

dist returns distance to other vector

pub fn to(self, b: Self) -> Self[src]

to returns vector from self to b

pub fn dot(self, b: Self) -> f32[src]

dot returns vectors dot

pub fn ang_to(self, b: Self) -> f32[src]

ang_to returns smallest angle between two vectors

pub fn trn<T: Fn(f32) -> f32>(&self, tr: T) -> Self[src]

trn applies closure to both x and y of a vector

pub fn inverted(&self) -> Self[src]

inverted inverts vector

pub fn round(&self) -> Self[src]

round rounds a vector

Trait Implementations

impl Add<Vect> for Vect[src]

type Output = Vect

The resulting type after applying the + operator.

impl AddAssign<Vect> for Vect[src]

impl Clone for Vect[src]

impl Copy for Vect[src]

impl Debug for Vect[src]

impl Default for Vect[src]

impl Div<Vect> for Vect[src]

type Output = Vect

The resulting type after applying the / operator.

impl Div<f32> for Vect[src]

type Output = Vect

The resulting type after applying the / operator.

impl DivAssign<Vect> for Vect[src]

impl DivAssign<f32> for Vect[src]

impl Mul<Vect> for Vect[src]

type Output = Vect

The resulting type after applying the * operator.

impl Mul<f32> for Vect[src]

type Output = Vect

The resulting type after applying the * operator.

impl MulAssign<Vect> for Vect[src]

impl MulAssign<f32> for Vect[src]

impl PartialEq<Vect> for Vect[src]

impl StructuralPartialEq for Vect[src]

impl Sub<Vect> for Vect[src]

type Output = Vect

The resulting type after applying the - operator.

impl SubAssign<Vect> for Vect[src]

Auto Trait Implementations

impl RefUnwindSafe for Vect

impl Send for Vect

impl Sync for Vect

impl Unpin for Vect

impl UnwindSafe for Vect

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>,