pub trait Transform: Sized {
    type Scalar: FloatingScalar;

    fn identity() -> 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 but_first(self, prev: Self) -> Self { ... } 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>
, { ... } }
Expand description

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.

Required Associated Types§

The scalar type

Required Methods§

Create a new identity transform

Chain this transform with another

Apply this transform to a vector

Create a translation from an offset vector

Create a rotation from a radian angle

Create a scaling from a ratio vector

Provided Methods§

Chain another transform with this one

Translate the transform

Rotate the transform

Scale the transform

Uniformly scale the transform

Rotate the transform about a pivot

Implementors§