#[repr(C)]pub struct Matrix4<T>where
T: Scalar,{
pub col: [Vector4<T>; 4],
}
Expand description
A 4x4 matrix stored in column-major order.
The standard matrix for 3D transformations using homogeneous coordinates.
§Layout
[m₀₀ m₀₁ m₀₂ m₀₃]
[m₁₀ m₁₁ m₁₂ m₁₃]
[m₂₀ m₂₁ m₂₂ m₂₃]
[m₃₀ m₃₁ m₃₂ m₃₃]
Fields§
§col: [Vector4<T>; 4]
Column vectors of the matrix
Implementations§
Source§impl<T> Matrix4<T>where
T: Scalar,
impl<T> Matrix4<T>where
T: Scalar,
pub fn new( m0: T, m1: T, m2: T, m3: T, m4: T, m5: T, m6: T, m7: T, m8: T, m9: T, m10: T, m11: T, m12: T, m13: T, m14: T, m15: T, ) -> Matrix4<T>
pub fn identity() -> Matrix4<T>
Sourcepub fn determinant(&self) -> T
pub fn determinant(&self) -> T
Computes the determinant of the matrix.
Uses Laplace expansion along the first column. A non-zero determinant indicates the matrix is invertible.
Sourcepub fn inverse(&self) -> Matrix4<T>
pub fn inverse(&self) -> Matrix4<T>
Computes the inverse of the matrix.
Uses the adjugate matrix method:
M⁻¹ = (1/det(M)) * adj(M)
§Note
Returns NaN or Inf if the matrix is singular (determinant = 0).
Sourcepub fn mul_matrix_matrix(l: &Matrix4<T>, r: &Matrix4<T>) -> Matrix4<T>
pub fn mul_matrix_matrix(l: &Matrix4<T>, r: &Matrix4<T>) -> Matrix4<T>
Multiplies two 4x4 matrices.
Matrix multiplication follows the rule:
C[i,j] = Σₖ A[i,k] * B[k,j]
pub fn mul_matrix_vector(l: &Matrix4<T>, r: &Vector4<T>) -> Vector4<T>
pub fn mul_vector_matrix(l: &Vector4<T>, r: &Matrix4<T>) -> Vector4<T>
Sourcepub fn add_matrix_matrix(l: &Matrix4<T>, r: &Matrix4<T>) -> Matrix4<T>
pub fn add_matrix_matrix(l: &Matrix4<T>, r: &Matrix4<T>) -> Matrix4<T>
Adds two matrices element-wise.
C[i,j] = A[i,j] + B[i,j]
Sourcepub fn sub_matrix_matrix(l: &Matrix4<T>, r: &Matrix4<T>) -> Matrix4<T>
pub fn sub_matrix_matrix(l: &Matrix4<T>, r: &Matrix4<T>) -> Matrix4<T>
Subtracts two matrices element-wise.
C[i,j] = A[i,j] - B[i,j]
Trait Implementations§
Source§impl AttributeDataTypeGetter for Matrix4<f32>
impl AttributeDataTypeGetter for Matrix4<f32>
Source§impl<T> Matrix4Extension<T> for Matrix4<T>where
T: Scalar,
impl<T> Matrix4Extension<T> for Matrix4<T>where
T: Scalar,
Source§impl UniformDataTypeGetter for Matrix4<f32>
impl UniformDataTypeGetter for Matrix4<f32>
impl<T> Copy for Matrix4<T>
Auto Trait Implementations§
impl<T> Freeze for Matrix4<T>where
T: Freeze,
impl<T> RefUnwindSafe for Matrix4<T>where
T: RefUnwindSafe,
impl<T> Send for Matrix4<T>where
T: Send,
impl<T> Sync for Matrix4<T>where
T: Sync,
impl<T> Unpin for Matrix4<T>where
T: Unpin,
impl<T> UnwindSafe for Matrix4<T>where
T: UnwindSafe,
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