pub type Mat4<T = f32> = Matrix<T, 4, 4>;
Expand description
A 4x4 matrix
Aliased Type§
struct Mat4<T = f32>(/* private fields */);
Implementations§
source§impl<T: Copy + NumAssign> Mat4<T>
impl<T: Copy + NumAssign> Mat4<T>
sourcepub fn det(&self) -> T
pub fn det(&self) -> T
Calculates the determinant of this matrix.
§Examples
let m = Mat4::<i32>::from_slice(&[1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1]);
assert_eq!(m.det(), -16);
sourcepub fn invert(&mut self) -> bool
pub fn invert(&mut self) -> bool
Invert this matrix. If this matrix is not invertible, this method returns false and the matrix is unchanged.
§Examples
let mut m = <Mat4>::from_slice(&[1., 1., 1., -1., 1., 1., -1., 1., 1., -1., 1., 1., -1., 1., 1., 1.]);
assert!(m.invert());
assert_eq!(*m.as_ref(), [0.25, 0.25, 0.25, -0.25, 0.25, 0.25, -0.25, 0.25, 0.25, -0.25, 0.25, 0.25, -0.25, 0.25, 0.25, 0.25]);
Trait Implementations§
source§impl<T: Copy + NumAssign> From<Matrix<T, 3, 3>> for Mat4<T>
impl<T: Copy + NumAssign> From<Matrix<T, 3, 3>> for Mat4<T>
source§fn from(m: Mat3<T>) -> Self
fn from(m: Mat3<T>) -> Self
Augments a Mat3
into a Mat4
The resulting Mat4
contains the given Mat3
on upper-left with the lower-right element = 1.
§Examples
let m = Mat4::from(Mat3::<i32>::from_slice(&[2, 3, 4, 5, 6, 7, 8, 9, 10]));
assert_eq!(*m.as_ref(), [2, 3, 4, 0, 5, 6, 7, 0, 8, 9, 10, 0, 0, 0, 0, 1]);