#[repr(C)]pub struct Mat3x3 {
pub m: [f32; 9],
}Expand description
A 3x3 transformation matrix for 2D transforms.
Stored in column-major order for OpenGL compatibility. The bottom row is always [0, 0, 1].
Layout:
| m[0] m[3] m[6] | | cos*sx -sin*sy tx |
| m[1] m[4] m[7] | = | sin*sx cos*sy ty |
| m[2] m[5] m[8] | | 0 0 1 |Fields§
§m: [f32; 9]Matrix elements in column-major order.
Implementations§
Source§impl Mat3x3
impl Mat3x3
Sourcepub const fn from_rows(
m00: f32,
m01: f32,
m02: f32,
m10: f32,
m11: f32,
m12: f32,
m20: f32,
m21: f32,
m22: f32,
) -> Mat3x3
pub const fn from_rows( m00: f32, m01: f32, m02: f32, m10: f32, m11: f32, m12: f32, m20: f32, m21: f32, m22: f32, ) -> Mat3x3
Creates a matrix from individual components.
Arguments are in row-major order for readability:
| m00 m01 m02 |
| m10 m11 m12 |
| m20 m21 m22 |Sourcepub fn translation(tx: f32, ty: f32) -> Mat3x3
pub fn translation(tx: f32, ty: f32) -> Mat3x3
Creates a translation matrix.
Sourcepub fn get_translation(&self) -> Vec2
pub fn get_translation(&self) -> Vec2
Returns the translation component.
Sourcepub fn transform_point(&self, point: Vec2) -> Vec2
pub fn transform_point(&self, point: Vec2) -> Vec2
Transforms a point by this matrix.
Sourcepub fn transform_direction(&self, direction: Vec2) -> Vec2
pub fn transform_direction(&self, direction: Vec2) -> Vec2
Transforms a direction by this matrix (ignores translation).
Sourcepub fn determinant(&self) -> f32
pub fn determinant(&self) -> f32
Computes the determinant of the matrix.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Mat3x3
impl<'de> Deserialize<'de> for Mat3x3
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Mat3x3, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Mat3x3, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<Mat3x3> for GlobalTransform2D
impl From<Mat3x3> for GlobalTransform2D
Source§fn from(matrix: Mat3x3) -> GlobalTransform2D
fn from(matrix: Mat3x3) -> GlobalTransform2D
Converts to this type from the input type.
Source§impl Serialize for Mat3x3
impl Serialize for Mat3x3
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Copy for Mat3x3
impl StructuralPartialEq for Mat3x3
Auto Trait Implementations§
impl Freeze for Mat3x3
impl RefUnwindSafe for Mat3x3
impl Send for Mat3x3
impl Sync for Mat3x3
impl Unpin for Mat3x3
impl UnsafeUnpin for Mat3x3
impl UnwindSafe for Mat3x3
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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>
Converts
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>
Converts
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().