[][src]Trait vector2math::Transform

pub trait Transform: Sized {
    type Scalar: FloatingScalar;
    fn new() -> Self;
fn then(self, next: Self) -> Self;
fn apply<V>(self, vector: V) -> V
    where
        V: Vector2<Scalar = Self::Scalar>
;
fn new_translate<V>(offset: V) -> Self
    where
        V: Vector2<Scalar = Self::Scalar>
;
fn new_rotate(radians: Self::Scalar) -> Self;
fn new_scale<V>(ratio: V) -> Self
    where
        V: Vector2<Scalar = Self::Scalar>
; fn translate<V>(self, offset: V) -> Self
    where
        V: Vector2<Scalar = Self::Scalar>
, { ... }
fn rotate(self, radians: Self::Scalar) -> Self { ... }
fn scale<V>(self, ratio: V) -> Self
    where
        V: Vector2<Scalar = Self::Scalar>
, { ... }
fn zoom(self, ratio: Self::Scalar) -> Self { ... }
fn rotate_about<V>(self, radians: Self::Scalar, pivot: V) -> Self
    where
        V: Vector2<Scalar = Self::Scalar>
, { ... } }

Trait for defining vector transformations

Transforms should be able to be chained without allocating extra space. The standard way to do this is with a matrix. For transforming 2D vectors, a 2×3 matrix can be used.

Associated Types

type Scalar: FloatingScalar

The scalar type

Loading content...

Required methods

fn new() -> Self

Create a new identity transform

fn then(self, next: Self) -> Self

Chain this transform with another

fn apply<V>(self, vector: V) -> V where
    V: Vector2<Scalar = Self::Scalar>, 

Apply this transform to a vector

fn new_translate<V>(offset: V) -> Self where
    V: Vector2<Scalar = Self::Scalar>, 

Create a translation from an offset vector

fn new_rotate(radians: Self::Scalar) -> Self

Create a rotation from a radian angle

fn new_scale<V>(ratio: V) -> Self where
    V: Vector2<Scalar = Self::Scalar>, 

Create a scaling from a ratio vector

Loading content...

Provided methods

fn translate<V>(self, offset: V) -> Self where
    V: Vector2<Scalar = Self::Scalar>, 

Translate the transform

fn rotate(self, radians: Self::Scalar) -> Self

Rotate the transform

fn scale<V>(self, ratio: V) -> Self where
    V: Vector2<Scalar = Self::Scalar>, 

Scale the transform

fn zoom(self, ratio: Self::Scalar) -> Self

Uniformly scale the transform

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

Rotate the transform about a pivot

Loading content...

Implementors

impl<M, C> Transform for M where
    M: Pair<Item = C>,
    C: Trio + Copy,
    C::Item: FloatingScalar
[src]

type Scalar = C::Item

Loading content...