Struct quicksilver::geom::Transform[][src]

pub struct Transform(_);

A 2D transformation represented by a matrix

Transforms can be composed together through matrix multiplication, and are applied to Vectors through multiplication, meaning the notation used is the '*' operator. A property of matrix multiplication is that for some matrices A, B, C and vector V is

Transform = A * B * C
Transform * V = A * (B * (C * V))

This property allows encoding multiple transformations in a single matrix. A transformation that involves rotating a shape 30 degrees and then moving it six units up could be written as

use quicksilver::geom::{Transform, Vector};
let transform = Transform::rotate(30) * Transform::translate(Vector::new(0, -6));

and then applied to a Vector

transform * Vector::new(5, 5)

Methods

impl Transform
[src]

Create an identity transformation

Create a rotation transformation

Create a translation transformation

Create a scale transformation

Convert the Transform into an nalgebra Matrix3

Find the inverse of a Transform

A transform's inverse will cancel it out when multplied with it, as seen below:

let transform = Transform::translate(Vector::new(4, 5));
let inverse = transform.inverse();
let vector = Vector::new(10, 10);
assert_eq!(vector, transform * inverse * vector);
assert_eq!(vector, inverse * transform * vector);

Trait Implementations

impl Clone for Transform
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Copy for Transform
[src]

impl Debug for Transform
[src]

Formats the value using the given formatter. Read more

impl Mul<Transform> for Transform
[src]

Concat two transforms A and B such that A * B * v = A * (B * v)

The resulting type after applying the * operator.

Performs the * operation.

impl Mul<Vector> for Transform
[src]

Transform a vector

The resulting type after applying the * operator.

Performs the * operation.

impl<T: Scalar> Mul<T> for Transform
[src]

Scale all of the internal values of the Transform matrix

Note this will NOT scale vectors multiplied by this transform, and generally you shouldn't need to use this.

The resulting type after applying the * operator.

Performs the * operation.

impl Display for Transform
[src]

Formats the value using the given formatter. Read more

impl Default for Transform
[src]

Returns the "default value" for a type. Read more

impl PartialEq for Transform
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for Transform
[src]

impl From<Matrix3<f32>> for Transform
[src]

Performs the conversion.

Auto Trait Implementations

impl Send for Transform

impl Sync for Transform