Struct oxygen_quark::matrix::matrix2x2::Matrix2x2
source · Fields§
§data: [Fraction; 4]
Implementations§
source§impl Matrix2x2
impl Matrix2x2
pub fn new() -> Matrix2x2
pub fn new_from_value(value: Fraction) -> Matrix2x2
pub fn new_from_values(values: &[Fraction]) -> Matrix2x2
pub fn add(self, other: Matrix2x2) -> Matrix2x2
pub fn subtract(self, other: Matrix2x2) -> Matrix2x2
pub fn multiply(&self, other: Matrix2x2) -> Matrix2x2
pub fn scale(&self, scale: Fraction) -> Matrix2x2
pub fn transpose(&self) -> Matrix2x2
pub fn cofactor(&self) -> Matrix2x2
pub fn adjugate(&self) -> Matrix2x2
pub fn determinant(&self) -> Fraction
sourcepub fn inverse(&self) -> Option<Matrix2x2>
pub fn inverse(&self) -> Option<Matrix2x2>
Returns an Option<Matrix2x2>
.
It returns an Option<Matrix2x2>
because there won’t always be an inverse (if the determinant is 0), hence requires some extra checking:
Example
let matrix1 = Matrix2x2::new();
let matrix2 = Matrix2x2::new_from_values(&values);
// println!("{}", matrix1.inverse().unwrap()); // Panics
// println!("{}", matrix2.inverse().unwrap()); // Works
Panics
Panics when trying to unwrap()
a None
-value.
sourcepub fn transform_vector2d(&self, other: &Vector2D) -> Vector2D
pub fn transform_vector2d(&self, other: &Vector2D) -> Vector2D
Returns a Vector2D
Trait Implementations§
source§impl AddAssign<Matrix2x2> for Matrix2x2
impl AddAssign<Matrix2x2> for Matrix2x2
source§fn add_assign(&mut self, other: Matrix2x2)
fn add_assign(&mut self, other: Matrix2x2)
Performs the
+=
operation. Read moresource§impl MulAssign<Matrix2x2> for Matrix2x2
impl MulAssign<Matrix2x2> for Matrix2x2
source§fn mul_assign(&mut self, other: Matrix2x2)
fn mul_assign(&mut self, other: Matrix2x2)
Performs the
*=
operation. Read moresource§impl SubAssign<Matrix2x2> for Matrix2x2
impl SubAssign<Matrix2x2> for Matrix2x2
source§fn sub_assign(&mut self, other: Matrix2x2)
fn sub_assign(&mut self, other: Matrix2x2)
Performs the
-=
operation. Read more