[][src]Trait vector2math::Vector2

pub trait Vector2: Copy {
    type Scalar: Scalar;
    fn x(self) -> Self::Scalar;
fn y(self) -> Self::Scalar;
fn new(x: Self::Scalar, y: Self::Scalar) -> Self; fn square(s: Self::Scalar) -> Self { ... }
fn map<V>(self) -> V
    where
        V: Vector2,
        V::Scalar: From<Self::Scalar>
, { ... }
fn map_with<V, F>(self, f: F) -> V
    where
        V: Vector2,
        F: FnMut(Self::Scalar) -> V::Scalar
, { ... }
fn add<V>(self, other: V) -> Self
    where
        V: Vector2<Scalar = Self::Scalar>
, { ... }
fn sub<V>(self, other: V) -> Self
    where
        V: Vector2<Scalar = Self::Scalar>
, { ... }
fn mul(self, by: Self::Scalar) -> Self { ... }
fn mul2<V>(self, other: V) -> Self
    where
        V: Vector2<Scalar = Self::Scalar>
, { ... }
fn div(self, by: Self::Scalar) -> Self { ... }
fn div2<V>(self, other: V) -> Self
    where
        V: Vector2<Scalar = Self::Scalar>
, { ... } }

Trait for manipulating 2D vectors

Associated Types

type Scalar: Scalar

The scalar type

Loading content...

Required methods

fn x(self) -> Self::Scalar

Get the x component

fn y(self) -> Self::Scalar

Get the y component

fn new(x: Self::Scalar, y: Self::Scalar) -> Self

Create a new vector from an x and y component

Loading content...

Provided methods

fn square(s: Self::Scalar) -> Self

Create a new square vector

fn map<V>(self) -> V where
    V: Vector2,
    V::Scalar: From<Self::Scalar>, 

Map this vector to a vector of another type

fn map_with<V, F>(self, f: F) -> V where
    V: Vector2,
    F: FnMut(Self::Scalar) -> V::Scalar

Map this vector to a vector of another type using a function

fn add<V>(self, other: V) -> Self where
    V: Vector2<Scalar = Self::Scalar>, 

Add the vector to another

fn sub<V>(self, other: V) -> Self where
    V: Vector2<Scalar = Self::Scalar>, 

Subtract another vector from this one

fn mul(self, by: Self::Scalar) -> Self

Multiply this vector by a scalar

fn mul2<V>(self, other: V) -> Self where
    V: Vector2<Scalar = Self::Scalar>, 

Multiply this vector component-wise by another

fn div(self, by: Self::Scalar) -> Self

Divide this vector by a scalar

fn div2<V>(self, other: V) -> Self where
    V: Vector2<Scalar = Self::Scalar>, 

Divide this vector component-wise by another

Loading content...

Implementors

impl<P> Vector2 for P where
    P: Pair + Copy,
    P::Item: Scalar
[src]

type Scalar = P::Item

fn square(s: Self::Scalar) -> Self
[src]

fn map<V>(self) -> V where
    V: Vector2,
    V::Scalar: From<Self::Scalar>, 
[src]

fn map_with<V, F>(self, f: F) -> V where
    V: Vector2,
    F: FnMut(Self::Scalar) -> V::Scalar
[src]

fn add<V>(self, other: V) -> Self where
    V: Vector2<Scalar = Self::Scalar>, 
[src]

fn sub<V>(self, other: V) -> Self where
    V: Vector2<Scalar = Self::Scalar>, 
[src]

fn mul(self, by: Self::Scalar) -> Self
[src]

fn mul2<V>(self, other: V) -> Self where
    V: Vector2<Scalar = Self::Scalar>, 
[src]

fn div(self, by: Self::Scalar) -> Self
[src]

fn div2<V>(self, other: V) -> Self where
    V: Vector2<Scalar = Self::Scalar>, 
[src]

Loading content...