[−][src]Struct quicksilver::geom::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.0) * Transform::translate(Vector::new(0.0, -6.0));
and then applied to a Vector
transform * Vector::new(5.0, 5.0)
Implementations
impl Transform
[src]
pub const IDENTITY: Transform
[src]
The identity transformation
pub fn rotate(angle: f32) -> Transform
[src]
Create a rotation transformation
pub fn translate(vec: Vector) -> Transform
[src]
Create a translation transformation
pub fn scale(vec: Vector) -> Transform
[src]
Create a scale transformation
pub fn orthographic(rect: Rectangle) -> Transform
[src]
Create an orthographic projection
pub fn then(self, next: Transform) -> Transform
[src]
#[must_use]pub fn inverse(&self) -> Transform
[src]
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.0, 5.0)); let inverse = transform.inverse(); let vector = Vector::new(10.0, 10.0); assert_eq!(vector, transform * inverse * vector); assert_eq!(vector, inverse * transform * vector);
Trait Implementations
impl Add<Transform> for Transform
[src]
Add the values of two transforms together
Note you probably want Mul to combine Transforms. Addition is only useful in less common use cases like interpolation
type Output = Transform
The resulting type after applying the +
operator.
fn add(self, other: Transform) -> Transform
[src]
impl AddAssign<Transform> for Transform
[src]
Uses the impl Add<Transform> for Transform
internally
fn add_assign(&mut self, other: Transform)
[src]
impl Clone for Transform
[src]
impl Copy for Transform
[src]
impl Debug for Transform
[src]
impl Default for Transform
[src]
impl Display for Transform
[src]
impl Eq for Transform
[src]
impl From<[[f32; 3]; 3]> for Transform
[src]
impl From<RowMatrix3<f32>> for Transform
[src]
fn from(mat: RowMatrix3<f32>) -> Transform
[src]
impl From<Transform> for [[f32; 3]; 3]
[src]
impl From<Transform> for RowMatrix3<f32>
[src]
fn from(trans: Transform) -> RowMatrix3<f32>
[src]
impl Mul<Transform> for Transform
[src]
Concat two transforms A and B such that A * B * v = A * (B * v)
type Output = Transform
The resulting type after applying the *
operator.
fn mul(self, other: Transform) -> Transform
[src]
impl Mul<Vector> for Transform
[src]
Transform a vector
type Output = Vector
The resulting type after applying the *
operator.
fn mul(self, other: Vector) -> Vector
[src]
impl Mul<f32> 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.
type Output = Transform
The resulting type after applying the *
operator.
fn mul(self, other: f32) -> Transform
[src]
impl MulAssign<Transform> for Transform
[src]
Uses the impl Mul<Transform> for Transform
internally.
fn mul_assign(&mut self, other: Transform)
[src]
impl MulAssign<f32> for Transform
[src]
Uses the impl Mul<f32> for Transform
internally.
fn mul_assign(&mut self, other: f32)
[src]
impl PartialEq<Transform> for Transform
[src]
impl Sub<Transform> for Transform
[src]
Subtract the values of one transform from another
Note you probably want Mul to combine Transforms. Subtraction is only useful in less common use cases like interpolation
type Output = Transform
The resulting type after applying the -
operator.
fn sub(self, other: Transform) -> Transform
[src]
impl SubAssign<Transform> for Transform
[src]
Uses the impl Sub<Transform> for Transform
internally
fn sub_assign(&mut self, other: Transform)
[src]
Auto Trait Implementations
impl RefUnwindSafe for Transform
impl Send for Transform
impl Sync for Transform
impl Unpin for Transform
impl UnwindSafe for Transform
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,