#[repr(C)]pub struct Mat2<T> {
pub a11: T,
pub a12: T,
pub a21: T,
pub a22: T,
}Expand description
2D transformation matrix.
Each field aij represents the i-th row and j-th column of the matrix.
Row-major storage with column-major semantics.
Stored in row-major order (fields appear in reading order),
but interpreted as column-major: each column is a transformed basis vector,
and matrices are applied to column vectors via mat * vec.
Fields§
§a11: T§a12: T§a21: T§a22: TImplementations§
Source§impl<T: Float> Mat2<T>
impl<T: Float> Mat2<T>
Source§impl<T> Mat2<T>
impl<T> Mat2<T>
Sourcepub fn transform2(self) -> Transform2<T>where
T: Zero,
pub fn transform2(self) -> Transform2<T>where
T: Zero,
Converts to a Transform2 matrix.
Sourcepub fn translate(self, trans: Vec2<T>) -> Transform2<T>
pub fn translate(self, trans: Vec2<T>) -> Transform2<T>
Adds a translation to the matrix.
Source§impl<T> Mat2<T>
impl<T> Mat2<T>
Sourcepub fn from_row_major(mat: [[T; 2]; 2]) -> Mat2<T>
pub fn from_row_major(mat: [[T; 2]; 2]) -> Mat2<T>
Imports the matrix from a row-major layout.
Sourcepub fn from_column_major(mat: [[T; 2]; 2]) -> Mat2<T>
pub fn from_column_major(mat: [[T; 2]; 2]) -> Mat2<T>
Imports the matrix from a column-major layout.
Sourcepub fn into_row_major(self) -> [[T; 2]; 2]
pub fn into_row_major(self) -> [[T; 2]; 2]
Exports the matrix as a row-major array.
Sourcepub fn into_column_major(self) -> [[T; 2]; 2]
pub fn into_column_major(self) -> [[T; 2]; 2]
Exports the matrix as a column-major array.
Source§impl<T: Scalar> Mat2<T>
impl<T: Scalar> Mat2<T>
Sourcepub fn flat_norm_sqr(self) -> T
pub fn flat_norm_sqr(self) -> T
Computes the squared Frobenius norm (sum of squares of all matrix elements).
This measure is useful for quickly checking matrix magnitude or comparing matrices without the cost of a square root operation.
To check if a matrix is effectively zero, test if flat_norm_sqr() is below a small epsilon threshold.
pub fn try_invert(self) -> Option<Mat2<T>>where
T: Float,
Trait Implementations§
Source§impl<T: Copy + Add<Output = T> + Mul<Output = T>> Mul<Mat2<T>> for Transform2<T>
impl<T: Copy + Add<Output = T> + Mul<Output = T>> Mul<Mat2<T>> for Transform2<T>
Source§type Output = Transform2<T>
type Output = Transform2<T>
* operator.Source§impl<T: Copy + Add<Output = T> + Mul<Output = T>> Mul<Transform2<T>> for Mat2<T>
impl<T: Copy + Add<Output = T> + Mul<Output = T>> Mul<Transform2<T>> for Mat2<T>
Source§type Output = Transform2<T>
type Output = Transform2<T>
* operator.Source§fn mul(self, rhs: Transform2<T>) -> Transform2<T>
fn mul(self, rhs: Transform2<T>) -> Transform2<T>
* operation. Read moreSource§impl<T> MulAssign<&Mat2<T>> for Mat2<T>
impl<T> MulAssign<&Mat2<T>> for Mat2<T>
Source§fn mul_assign(&mut self, rhs: &Mat2<T>)
fn mul_assign(&mut self, rhs: &Mat2<T>)
*= operation. Read moreSource§impl<T> MulAssign<&T> for Mat2<T>
impl<T> MulAssign<&T> for Mat2<T>
Source§fn mul_assign(&mut self, rhs: &T)
fn mul_assign(&mut self, rhs: &T)
*= operation. Read moreSource§impl<T: Copy + Add<Output = T> + Mul<Output = T>> MulAssign<Mat2<T>> for Transform2<T>
impl<T: Copy + Add<Output = T> + Mul<Output = T>> MulAssign<Mat2<T>> for Transform2<T>
Source§fn mul_assign(&mut self, rhs: Mat2<T>)
fn mul_assign(&mut self, rhs: Mat2<T>)
*= operation. Read moreSource§impl<T: Copy + MulAssign> MulAssign<T> for Mat2<T>
impl<T: Copy + MulAssign> MulAssign<T> for Mat2<T>
Source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
*= operation. Read moreSource§impl<T: Copy + Add<Output = T> + Mul<Output = T>> MulAssign for Mat2<T>
impl<T: Copy + Add<Output = T> + Mul<Output = T>> MulAssign for Mat2<T>
Source§fn mul_assign(&mut self, rhs: Mat2<T>)
fn mul_assign(&mut self, rhs: Mat2<T>)
*= operation. Read more