[][src]Trait pane::math::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 map<V>(&self) -> V
    where
        V: Vector2,
        V::Scalar: From<Self::Scalar>
, { ... }
fn neg(self) -> Self { ... }
fn add<V: Vector2<Scalar = Self::Scalar>>(self, other: V) -> Self { ... }
fn sub<V: Vector2<Scalar = Self::Scalar>>(self, other: V) -> Self { ... }
fn mul(self, by: Self::Scalar) -> Self { ... }
fn mul2<V: Vector2<Scalar = Self::Scalar>>(self, other: V) -> Self { ... }
fn div(self, by: Self::Scalar) -> Self { ... }
fn div2<V: Vector2<Scalar = Self::Scalar>>(self, other: V) -> Self { ... }
fn dist<V: Vector2<Scalar = Self::Scalar>>(self, to: V) -> Self::Scalar { ... }
fn mag(self) -> Self::Scalar { ... }
fn rotate_about<V: Vector2<Scalar = Self::Scalar> + Clone>(
        self,
        pivot: V,
        radians: Self::Scalar
    ) -> Self { ... } }

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 map<V>(&self) -> V where
    V: Vector2,
    V::Scalar: From<Self::Scalar>, 

Map this vector to a vector of another type

fn neg(self) -> Self

Negate the vector

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

Add the vector to another

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

Subtract another vector from this one

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

Multiply this vector by a scalar

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

Multiply this vector component-wise by another

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

Divide this vector by a scalar

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

Divide this vector component-wise by another

fn dist<V: Vector2<Scalar = Self::Scalar>>(self, to: V) -> Self::Scalar

Get the distance between this vector and another

fn mag(self) -> Self::Scalar

Get the vector's magnitude

fn rotate_about<V: Vector2<Scalar = Self::Scalar> + Clone>(
    self,
    pivot: V,
    radians: Self::Scalar
) -> Self

Rotate the vector some number of radians about a pivot

Loading content...

Implementors

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

type Scalar = P::Item

Loading content...