pub struct Matrix2x2 { /* private fields */ }Expand description
Matrice 2×2 en f32, stockée en row-major.
use embedded_matrix::Matrix2x2;
let m = Matrix2x2::new([[1.0, 2.0], [3.0, 4.0]]);
assert!((m.det() - (-2.0)).abs() < 1e-5);
assert_eq!(m[(1, 0)], 3.0);Implementations§
Source§impl Matrix2x2
impl Matrix2x2
Sourcepub const fn new(data: [[f32; 2]; 2]) -> Self
pub const fn new(data: [[f32; 2]; 2]) -> Self
Crée une matrice à partir d’un tableau row-major.
Sourcepub const fn from_diagonal(d: [f32; 2]) -> Self
pub const fn from_diagonal(d: [f32; 2]) -> Self
Matrice diagonale.
Sourcepub fn get(&self, row: usize, col: usize) -> f32
pub fn get(&self, row: usize, col: usize) -> f32
Retourne l’élément à la ligne row et colonne col (0-indexé).
§Panics
Panique si row ou col vaut 2 ou plus.
Sourcepub fn approx_eq(&self, other: &Self, tol: f32) -> bool
pub fn approx_eq(&self, other: &Self, tol: f32) -> bool
Compare deux matrices terme à terme avec une tolérance absolue.
Renvoie false si un terme est NaN.
Sourcepub fn inv(&self) -> Result<Self, MatrixError>
pub fn inv(&self) -> Result<Self, MatrixError>
Inverse de la matrice.
§Errors
MatrixError::SingularMatrixsi|det|est négligeable devant|ad| + |bc|(seuil relatif, voir la doc de la crate).MatrixError::NonFiniteValuesi la matrice contient NaN / ±∞ ou si le calcul déborde.
Trait Implementations§
Source§impl AddAssign for Matrix2x2
impl AddAssign for Matrix2x2
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moreimpl Copy for Matrix2x2
Source§impl MulAssign for Matrix2x2
impl MulAssign for Matrix2x2
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*= operation. Read moreSource§impl MulAssign<f32> for Matrix2x2
impl MulAssign<f32> for Matrix2x2
Source§fn mul_assign(&mut self, s: f32)
fn mul_assign(&mut self, s: f32)
Performs the
*= operation. Read moreimpl StructuralPartialEq for Matrix2x2
Auto Trait Implementations§
impl Freeze for Matrix2x2
impl RefUnwindSafe for Matrix2x2
impl Send for Matrix2x2
impl Sync for Matrix2x2
impl Unpin for Matrix2x2
impl UnsafeUnpin for Matrix2x2
impl UnwindSafe for Matrix2x2
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