Trait 2dgl::data::vector::Vector2 [-]  [+] [src]

pub trait Vector2<T>: Add<Self, Self> + Sub<Self, Self> + Mul<T, Self> + Div<T, Self> + Neg<Self> + Zero {
    fn from_vector2<V: Vector2<T>>(v: &V) -> Self;
    fn x(&self) -> T;
    fn y(&self) -> T;
    fn magnitude(&self) -> T;
    fn direction(&self) -> T;
    fn dot_product<V: Vector2<T>>(&self, other: &V) -> T;
    fn project<V: Vector2<T>>(&self, other: &V) -> V;
    fn unit(&self) -> Self;
}

Generalized two dimensional vector

Required Methods

fn from_vector2<V: Vector2<T>>(v: &V) -> Self

Constructor for constructing from a generalized vector

fn x(&self) -> T

The x coordinate that this vector represents

fn y(&self) -> T

The y coordinate that this vector represents

fn magnitude(&self) -> T

The magnitude/length of this vector

fn direction(&self) -> T

The direction/angle of this vector

fn dot_product<V: Vector2<T>>(&self, other: &V) -> T

fn project<V: Vector2<T>>(&self, other: &V) -> V

Projection of self on other

fn unit(&self) -> Self

The unit vector (Length set to 1 but still having the same direction) of this vector

Implementors