pub struct Transform(/* private fields */);Expand description
A 3x2 transformation matrix representing an affine transform.
In other words, it is a 2x2 transformation matrix with a translation component, or a 3x3 homogenous transform matrix.
Implementations§
source§impl Transform
impl Transform
pub const IDENTITY: Transform = _
sourcepub const fn new(
m00: f32,
m01: f32,
m10: f32,
m11: f32,
tx: f32,
ty: f32,
) -> Transform
pub const fn new( m00: f32, m01: f32, m10: f32, m11: f32, tx: f32, ty: f32, ) -> Transform
Creates a matrix from each individual element.
The matrix is in column-major order, that is:
$$ \begin{bmatrix} \texttt{m00} & \texttt{m10} & \texttt{tx} \\ \texttt{m01} & \texttt{m11} & \texttt{ty} \\ 0 & 0 & 1 \end{bmatrix} $$
sourcepub const fn translation(tx: f32, ty: f32) -> Transform
pub const fn translation(tx: f32, ty: f32) -> Transform
Creates a transform that performs a translation.
$$ \begin{bmatrix} 1 & 0 & \texttt{tx} \\ 0 & 1 & \texttt{ty} \\ 0 & 0 & 1 \end{bmatrix} $$
sourcepub const fn scaling(sx: f32, sy: f32) -> Transform
pub const fn scaling(sx: f32, sy: f32) -> Transform
Creates a transform that performs scaling.
$$ \begin{bmatrix} \texttt{sx} & 0 & 0 \\ 0 & \texttt{sy} & 0 \\ 0 & 0 & 1 \end{bmatrix} $$
sourcepub fn rotation(theta: f32) -> Transform
pub fn rotation(theta: f32) -> Transform
Creates a transform that performs a rotation.
$$ \begin{bmatrix} \text{cos}\ \theta & -\text{sin}\ \theta & 0 \\ \text{sin}\ \theta & \text{cos}\ \theta & 0 \\ 0 & 0 & 1 \end{bmatrix} $$
sourcepub const fn determinant(&self) -> f32
pub const fn determinant(&self) -> f32
Computes the determinant of the matrix.
Trait Implementations§
source§impl MulAssign for Transform
impl MulAssign for Transform
source§fn mul_assign(&mut self, rhs: Transform)
fn mul_assign(&mut self, rhs: Transform)
*= operation. Read moreimpl Copy for Transform
Auto Trait Implementations§
impl Freeze for Transform
impl RefUnwindSafe for Transform
impl Send for Transform
impl Sync for Transform
impl Unpin for Transform
impl UnwindSafe for Transform
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more