#[repr(C)]pub struct Matrix3<T>where
T: Scalar,{
pub col: [Vector3<T>; 3],
}
Expand description
A 3x3 matrix stored in column-major order.
Commonly used for 2D transformations (with homogeneous coordinates) and 3D rotations.
§Layout
[m₀₀ m₀₁ m₀₂]
[m₁₀ m₁₁ m₁₂]
[m₂₀ m₂₁ m₂₂]
Fields§
§col: [Vector3<T>; 3]
Column vectors of the matrix
Implementations§
Source§impl<T> Matrix3<T>where
T: Scalar,
impl<T> Matrix3<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, ) -> Matrix3<T>
pub fn identity() -> Matrix3<T>
pub fn determinant(&self) -> T
Sourcepub fn inverse(&self) -> Matrix3<T>
pub fn inverse(&self) -> Matrix3<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: &Matrix3<T>, r: &Matrix3<T>) -> Matrix3<T>
pub fn mul_matrix_matrix(l: &Matrix3<T>, r: &Matrix3<T>) -> Matrix3<T>
Multiplies two 3x3 matrices.
Matrix multiplication follows the rule:
C[i,j] = Σₖ A[i,k] * B[k,j]
Sourcepub fn mul_matrix_vector(l: &Matrix3<T>, r: &Vector3<T>) -> Vector3<T>
pub fn mul_matrix_vector(l: &Matrix3<T>, r: &Vector3<T>) -> Vector3<T>
Multiplies a 3x3 matrix by a 3D vector.
Transforms the vector by the matrix:
v' = M * v
Sourcepub fn mul_vector_matrix(l: &Vector3<T>, r: &Matrix3<T>) -> Vector3<T>
pub fn mul_vector_matrix(l: &Vector3<T>, r: &Matrix3<T>) -> Vector3<T>
Multiplies a 3D vector by a 3x3 matrix (row vector).
v' = vᵀ * M
Sourcepub fn add_matrix_matrix(l: &Matrix3<T>, r: &Matrix3<T>) -> Matrix3<T>
pub fn add_matrix_matrix(l: &Matrix3<T>, r: &Matrix3<T>) -> Matrix3<T>
Adds two matrices element-wise.
C[i,j] = A[i,j] + B[i,j]
Sourcepub fn sub_matrix_matrix(l: &Matrix3<T>, r: &Matrix3<T>) -> Matrix3<T>
pub fn sub_matrix_matrix(l: &Matrix3<T>, r: &Matrix3<T>) -> Matrix3<T>
Subtracts two matrices element-wise.
C[i,j] = A[i,j] - B[i,j]
Source§impl<T> Matrix3<T>where
T: FloatScalar,
impl<T> Matrix3<T>where
T: FloatScalar,
Sourcepub fn of_axis_angle(axis: &Vector3<T>, angle: T) -> Matrix3<T>
pub fn of_axis_angle(axis: &Vector3<T>, angle: T) -> Matrix3<T>
Creates a 3x3 rotation matrix from an axis and angle.
Uses Rodrigues’ rotation formula:
R = I + sin(θ)K + (1 - cos(θ))K²
where K is the cross-product matrix of the normalized axis.
§Parameters
axis
: The rotation axis (will be normalized)angle
: The rotation angle in radians
Trait Implementations§
Source§impl AttributeDataTypeGetter for Matrix3<f32>
impl AttributeDataTypeGetter for Matrix3<f32>
Source§impl UniformDataTypeGetter for Matrix3<f32>
impl UniformDataTypeGetter for Matrix3<f32>
impl<T> Copy for Matrix3<T>
Auto Trait Implementations§
impl<T> Freeze for Matrix3<T>where
T: Freeze,
impl<T> RefUnwindSafe for Matrix3<T>where
T: RefUnwindSafe,
impl<T> Send for Matrix3<T>where
T: Send,
impl<T> Sync for Matrix3<T>where
T: Sync,
impl<T> Unpin for Matrix3<T>where
T: Unpin,
impl<T> UnwindSafe for Matrix3<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