Struct oxygen_quark::matrix::matrix2x2::Matrix2x2
source · Fields§
§data: [Fraction; 4]
The matrix data.
Implementations§
source§impl Matrix2x2
impl Matrix2x2
sourcepub fn new_from_value(value: Fraction) -> Matrix2x2
pub fn new_from_value(value: Fraction) -> Matrix2x2
Generates a new Matrix2x2
from the Fraction
specified.
sourcepub fn new_from_values(values: &[Fraction]) -> Matrix2x2
pub fn new_from_values(values: &[Fraction]) -> Matrix2x2
Generates a new Matrix2x2
from a list of Fraction
values.
sourcepub fn scale(&self, scale: Fraction) -> Matrix2x2
pub fn scale(&self, scale: Fraction) -> Matrix2x2
Scales the given Matrix2x2
by the given Fraction
.
sourcepub fn adjugate(&self) -> Matrix2x2
pub fn adjugate(&self) -> Matrix2x2
Returns the adjugate of the Matrix2x2
.
Equal to calling cofactor() and then transpose().
sourcepub fn determinant(&self) -> Fraction
pub fn determinant(&self) -> Fraction
Calculates the determinant of the Matrix2x2
and returns it, a 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.
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
Transforms a Vector2D
with the Matrix2x2
and returns the result, 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