[−][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) * Transform::translate(Vector::new(0, -6));
and then applied to a Vector
transform * Vector::new(5, 5)
Methods
impl Transform
[src]
pub const IDENTITY: Transform
[src]
The identity transformation
pub fn from_array(array: [[f32; 3]; 3]) -> Transform
[src]
Create a Transform from an arbitrary matrix in a column-major matrix
pub fn rotate<T: Scalar>(angle: T) -> Transform
[src]
Create a rotation transformation
pub fn translate(
vec: impl Into<Vector>
) -> Transform
[src]
vec: impl Into<Vector>
) -> Transform
Create a translation transformation
pub fn scale(
vec: impl Into<Vector>
) -> Transform
[src]
vec: impl Into<Vector>
) -> Transform
Create a scale transformation
pub fn into_matrix(self) -> Matrix3<f32>
[src]
Convert the Transform into an nalgebra Matrix3
#[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, 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 Eq for Transform
[src]
impl Clone for Transform
[src]
fn clone(&self) -> Transform
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Copy for Transform
[src]
impl PartialEq<Transform> for Transform
[src]
fn eq(&self, other: &Transform) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Default for Transform
[src]
impl From<Matrix<f32, U3, U3, <DefaultAllocator as Allocator<f32, U3, U3>>::Buffer>> for Transform
[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<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.
type Output = Transform
The resulting type after applying the *
operator.
fn mul(self, other: T) -> Transform
[src]
impl Debug for Transform
[src]
impl Display for Transform
[src]
impl Serialize for Transform
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de> Deserialize<'de> for Transform
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)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> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
Sets value
as a parameter of self
.
impl<T> Erased for T
impl<T> Scalar for T where
T: Copy + PartialEq<T> + Any + Debug,
[src]
T: Copy + PartialEq<T> + Any + Debug,
impl<T> Same for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf for SP where
SS: SubsetOf<SP>,
[src]
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
[src]
fn is_in_subset(&self) -> bool
[src]
unsafe fn to_subset_unchecked(&self) -> SS
[src]
fn from_subset(element: &SS) -> SP
[src]
impl<T> Downcast for T where
T: Any,
T: Any,
fn into_any(self: Box<T>) -> Box<dyn Any + 'static>
fn as_any(&self) -> &(dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
impl<Q, K> Equivalent for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,