pub struct Matrix3 {
pub m00: f64,
pub m01: f64,
pub m02: f64,
pub m10: f64,
pub m11: f64,
pub m12: f64,
pub m20: f64,
pub m21: f64,
pub m22: f64,
}Expand description
A 3x3 matrix stored in row-major order.
§Examples
use use_matrix::Matrix3;
let matrix = Matrix3::new(
1.0, 2.0, 3.0,
0.0, 1.0, 4.0,
5.0, 6.0, 0.0,
);
assert_eq!(matrix.determinant(), 1.0);Fields§
§m00: f64§m01: f64§m02: f64§m10: f64§m11: f64§m12: f64§m20: f64§m21: f64§m22: f64Implementations§
Source§impl Matrix3
impl Matrix3
Sourcepub const IDENTITY: Self
pub const IDENTITY: Self
The identity matrix.
§Examples
use use_matrix::Matrix3;
let matrix = Matrix3::new(
2.0, 1.0, 0.0,
0.0, 3.0, 4.0,
0.0, 0.0, 5.0,
);
assert_eq!(Matrix3::IDENTITY * matrix, matrix);Sourcepub const fn new(
m00: f64,
m01: f64,
m02: f64,
m10: f64,
m11: f64,
m12: f64,
m20: f64,
m21: f64,
m22: f64,
) -> Self
pub const fn new( m00: f64, m01: f64, m02: f64, m10: f64, m11: f64, m12: f64, m20: f64, m21: f64, m22: f64, ) -> Self
Creates a matrix from row-major entries.
Sourcepub const fn determinant(self) -> f64
pub const fn determinant(self) -> f64
Returns the determinant.
Sourcepub fn inverse(self) -> Option<Self>
pub fn inverse(self) -> Option<Self>
Returns the inverse when the determinant is finite and non-zero.
Returns None for singular matrices or matrices with non-finite
determinants.
§Examples
use use_matrix::Matrix3;
let matrix = Matrix3::new(
1.0, 2.0, 3.0,
0.0, 1.0, 4.0,
5.0, 6.0, 0.0,
);
let inverse = matrix.inverse().expect("matrix should invert");
assert_eq!(matrix * inverse, Matrix3::IDENTITY);Trait Implementations§
impl Copy for Matrix3
impl StructuralPartialEq for Matrix3
Auto Trait Implementations§
impl Freeze for Matrix3
impl RefUnwindSafe for Matrix3
impl Send for Matrix3
impl Sync for Matrix3
impl Unpin for Matrix3
impl UnsafeUnpin for Matrix3
impl UnwindSafe for Matrix3
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