pub struct Mat3 {
pub a: f64,
pub b: f64,
pub c: f64,
pub d: f64,
pub e: f64,
pub f: f64,
pub g: f64,
pub h: f64,
pub i: f64,
}Expand description
a 3×3 matrix of f64 values.
The matrix is stored in row-major order:
| a b c |
| c d e |
| g h i |Fields§
§a: f64First row, first column element.
b: f64First row, second column element.
c: f64First row, third column element.
d: f64Second row, first column element.
e: f64Second row, second column element.
f: f64Second row, third column element.
g: f64Third row, first column element.
h: f64Third row, second column element.
i: f64Third row, third column element.
Implementations§
Source§impl Mat3
impl Mat3
Sourcepub fn determinant(&self) -> f64
pub fn determinant(&self) -> f64
Returns the determinant of the matrix.
Computed as: [ \det(M) = a(ei - fh) - b(di - fg) + c(dh - eg) ]
§Examples
use lars::Mat3;
let m = Mat3::new(1.0, 2.0, 3.0, 3.0, 2.0, 1.0, 2.0, 1.0, 3.0);
assert_eq!(m.determinant(), -12.0);Sourcepub fn inverse(&self) -> Mat3
pub fn inverse(&self) -> Mat3
Returns the inverse of the matrix, if it exists.
Computed as: M⁻¹ = (1/det(M)) * adj(M) / 1 | ei - fh ch - bi bf - ce | M⁻¹ = —–– x | fg - di ai - cg cd - af | det(M) | dh - eg bg - ah ae - bd |
§Panics
Panics if the matrix is singular (determinant = 0).
§Examples
use lars::Mat3;
let m = Mat3::new(1.0, 2.0, 3.0, 3.0, 2.0, 1.0, 2.0, 1.0, 3.0);
assert_eq!(m.inverse(), Mat3::new(-5.0, 3.0, 4.0, 7.0, 3.0, -8.0, 1.0, -3.0, 4.0)/12.0);Trait Implementations§
Source§impl PartialOrd for Mat3
impl PartialOrd for Mat3
impl Copy for Mat3
Auto Trait Implementations§
impl Freeze for Mat3
impl RefUnwindSafe for Mat3
impl Send for Mat3
impl Sync for Mat3
impl Unpin for Mat3
impl UnwindSafe for Mat3
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