Struct Matrix3

Source
pub struct Matrix3<T> {
    pub m: [[T; 3]; 3],
}
Expand description

A 3 x 3 Matrix with row major order

Fields§

§m: [[T; 3]; 3]

Implementations§

Source§

impl<T> Matrix3<T>

Source

pub fn new(row0: [T; 3], row1: [T; 3], row2: [T; 3]) -> Self

Source

pub fn new_val( r0c0: T, r0c1: T, r0c2: T, r1c0: T, r1c1: T, r1c2: T, r2c0: T, r2c1: T, r2c2: T, ) -> Self

Source

pub fn identity() -> Self
where T: Zero + One,

return the identity

Source

pub fn trace(&self) -> T
where T: Add<T, Output = T> + Copy,

the trace …

Source

pub fn determinant(&self) -> T
where T: Add<T, Output = T> + Sub<T, Output = T> + Mul<T, Output = T> + Copy,

Calculate the determinant

§Arguments
  • self - The Matrix3 the function was called for
Source

pub fn transpose(&self) -> Matrix3<T>
where T: Copy,

Return a transposed matrix transpose matrix (a, b, c) (d, e, f) (g, h, i)

matrix (a, d, g) (b, e, h) (c, f, i)

use feo_math::linear_algebra::matrix3::Matrix3;
let transposed = Matrix3::new(
    [0.0,2.0,2.0],
    [1.0,0.0,2.0],
    [1.0,1.0,0.0]
).transpose();
let result = Matrix3::new(
    [0.0,1.0,1.0],
    [2.0,0.0,1.0],
    [2.0,2.0,0.0]
);
assert_eq!(transposed, result);
Source

pub fn eigen_value(&self) -> [Option<T>; 3]
where T: F32Fmt<F32Fmt = f32> + Add<T, Output = T> + Sub<T, Output = T> + Mul<T, Output = T> + Div<T, Output = T> + Neg<Output = T> + SignOps + F32Fmt + Zero + One + Three + PartialEq + Copy + Rem<T, Output = T> + Two + Primitive + Debug,

Rule: Mv = λv where M = a matrix λ = an eigenvalue v = a eigenvector

as a 3x3 Matrix can have

if v != <0, 0, 0> then: … // self expl todo |M - Iλ| = 0 … // in fn

Source

pub fn eigen_vector(&self, eigen_value: T) -> Vector3<T>
where T: Add<T, Output = T> + Sub<T, Output = T> + Mul<T, Output = T> + Div<T, Output = T> + Debug + Zero + One + Copy,

Source

pub fn cofactor(self) -> Self
where T: Mul<T, Output = T> + Neg<Output = T> + Sub<T, Output = T> + Copy,

Get the cofactor matrix of a 3x3 matrix.

Source

pub fn adjugate(self) -> Self
where T: Mul<T, Output = T> + Neg<Output = T> + Sub<T, Output = T> + Copy,

Get the adjugate matrix of a 3x3 matrix.

Source

pub fn inverse(&self) -> Self
where T: Add<T, Output = T> + Sub<T, Output = T> + Mul<T, Output = T> + Div<T, Output = T> + Neg<Output = T> + Copy,

Get the inverse of a 3x3 matrix.

use feo_math::linear_algebra::matrix3::Matrix3;
let mat0 = Matrix3::new(
    [1, 1, 0],
    [0, 1, 0],
    [1, 0, 1],
);
let expected = Matrix3::new(
    [ 1, -1,  0],
    [ 0,  1,  0],
    [-1,  1,  1],
);
assert_eq!(mat0.inverse(), expected);
§Arguments
  • self - The matrix the function is being called for

Trait Implementations§

Source§

impl<T> Add<T> for Matrix3<T>
where T: Add<T, Output = T> + Copy,

Source§

fn add(self, rhs: T) -> Self::Output

Matrix3 + T = Matrix3

§Examples
use feo_math::linear_algebra::vector3::Vector3;
use feo_math::linear_algebra::matrix3::Matrix3;
let mat = Matrix3::new(
    [1, 2, 3],
    [2, 3, 1],
    [3, 1, 2]
);
let val = 2;
let expected = Matrix3::new(
    [3, 4, 5],
    [4, 5, 3],
    [5, 3, 4]
);
assert_eq!(mat + val, expected);
Source§

type Output = Matrix3<T>

The resulting type after applying the + operator.
Source§

impl<T> Add for Matrix3<T>
where T: Add<T, Output = T> + Copy,

Source§

fn add(self, rhs: Self) -> Self::Output

Matrix3 + Matrix3 = Matrix3

§Examples
use feo_math::linear_algebra::vector3::Vector3;
use feo_math::linear_algebra::matrix3::Matrix3;
let mat0 = Matrix3::new(
    [4, 5, 6],
    [6, 4, 5],
    [5, 6, 4]
);
let mat1 = Matrix3::new(
    [1, 2, 3],
    [2, 3, 1],
    [3, 1, 2]
);
let expected = Matrix3::new(
    [5, 7, 9],
    [8, 7, 6],
    [8, 7, 6] 
);
assert_eq!(mat0 + mat1, expected);
Source§

type Output = Matrix3<T>

The resulting type after applying the + operator.
Source§

impl<T: Clone> Clone for Matrix3<T>

Source§

fn clone(&self) -> Matrix3<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for Matrix3<T>
where T: Debug + Copy,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Div<T> for Matrix3<T>
where T: Div<T, Output = T> + Copy,

Source§

fn div(self, rhs: T) -> Self::Output

Matrix3 / T = Matrix3

§Examples
use feo_math::linear_algebra::vector3::Vector3;
use feo_math::linear_algebra::matrix3::Matrix3;
let mat = Matrix3::new(
    [1, 2, 3],
    [2, 3, 1],
    [3, 1, 2]
);
let val = 2;
let expected = Matrix3::new(
    [0, 1, 1],
    [1, 1, 0],
    [1, 0, 1]
);
assert_eq!(mat / val, expected);
use feo_math::linear_algebra::vector3::Vector3;
use feo_math::linear_algebra::matrix3::Matrix3;
let mat = Matrix3::new(
    [1, 2, 3],
    [2, 3, 1],
    [3, 1, 2]
);
mat / 0;
Source§

type Output = Matrix3<T>

The resulting type after applying the / operator.
Source§

impl<T> Div for Matrix3<T>
where T: Add<T, Output = T> + Sub<T, Output = T> + Mul<T, Output = T> + Div<T, Output = T> + Neg<Output = T> + Copy,

Source§

fn div(self, rhs: Self) -> Self::Output

Matrix3 / Matrix3 = Matrix3

§Examples
use feo_math::linear_algebra::vector3::Vector3;
use feo_math::linear_algebra::matrix3::Matrix3;
let mat0 = Matrix3::new(
    [4, 5, 6],
    [6, 4, 5],
    [5, 6, 4]
);
let mat1 = Matrix3::new(
    [1, 2, 3],
    [2, 3, 1],
    [3, 1, 2]
);
let expected = Matrix3::new(
    [1, 0, 0],
    [0, 0, 1],
    [0, 1, 0] 
);
assert_eq!(mat0 / mat1, expected);
Source§

type Output = Matrix3<T>

The resulting type after applying the / operator.
Source§

impl<T> F32Fmt for Matrix3<T>
where T: F32Fmt + Copy,

Source§

type F32Fmt = Matrix3<<T as F32Fmt>::F32Fmt>

Source§

fn intoF32Fmt(self) -> Self::F32Fmt

Source§

fn fromF32Fmt(f32_fmt: Self::F32Fmt) -> Self

Source§

fn sqrt(self) -> Self

Source§

fn cbrt(self) -> Self

Source§

fn f32_const_mul(self, constant: f32) -> Self

Source§

fn sin_mul(self, _mul_by: Self) -> Self
where Self: Mul<Self, Output = Self> + Sized,

Source§

fn cos_mul(self, _mul_by: Self) -> Self
where Self: Mul<Self, Output = Self> + Sized,

Source§

fn tan_mul(self, _mul_by: Self) -> Self
where Self: Mul<Self, Output = Self> + Sized,

Source§

fn asin_mul(self, _mul_by: Self) -> Self
where Self: Mul<Self, Output = Self> + Sized,

Source§

fn acos_mul(self, _mul_by: Self) -> Self
where Self: Mul<Self, Output = Self> + Sized,

Source§

fn atan_mul(self, _mul_by: Self) -> Self
where Self: Mul<Self, Output = Self> + Sized,

Source§

fn atan2_mul(self, _other: Self, _mul_by: Self) -> Self
where Self: Mul<Self, Output = Self> + Sized,

Source§

fn sinh_mul(self, _mul_by: Self) -> Self
where Self: Mul<Self, Output = Self> + Sized,

Source§

fn cosh_mul(self, _mul_by: Self) -> Self
where Self: Mul<Self, Output = Self> + Sized,

Source§

fn tanh_mul(self, _mul_by: Self) -> Self
where Self: Mul<Self, Output = Self> + Sized,

Source§

impl<T> From<Axes<T>> for Matrix3<T>
where T: Copy,

Source§

fn from(other: Axes<T>) -> Matrix3<T>

Converts to this type from the input type.
Source§

impl<T> From<Euler<T>> for Matrix3<T>

Source§

fn from(_: Euler<T>) -> Matrix3<T>

Converts to this type from the input type.
Source§

impl<T> From<Matrix3<T>> for [[T; 3]; 3]

Source§

fn from(other: Matrix3<T>) -> [[T; 3]; 3]

Converts to this type from the input type.
Source§

impl<T> From<Matrix3<T>> for Axes<T>
where T: Mul<T, Output = T> + Div<T, Output = T> + F32Fmt + Add<T, Output = T> + Copy,

Source§

fn from(mat: Matrix3<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Matrix3<T>> for Euler<T>

Source§

fn from(_: Matrix3<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Matrix3<T>> for Matrix4<T>
where T: One + Zero + Copy,

Source§

fn from(mat3: Matrix3<T>) -> Matrix4<T>

Converts to this type from the input type.
Source§

impl<T> From<Matrix3<T>> for Quaternion<T>
where T: F32Fmt + Add<T, Output = T> + Sub<T, Output = T> + Div<T, Output = T> + Mul<T, Output = T> + Debug + Two + One + Zero + Copy,

Source§

fn from(mat3: Matrix3<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Matrix3<T>> for Rotor<T>

Source§

fn from(_: Matrix3<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Quaternion<T>> for Matrix3<T>
where T: Add<T, Output = T> + Sub<T, Output = T> + Mul<T, Output = T> + Div<T, Output = T> + Neg<Output = T> + Copy + One + Two,

Source§

fn from(other: Quaternion<T>) -> Matrix3<T>

Converts to this type from the input type.
Source§

impl<T> From<Rotor<T>> for Matrix3<T>

Source§

fn from(_: Rotor<T>) -> Matrix3<T>

Converts to this type from the input type.
Source§

impl<T> Mul<T> for Matrix3<T>
where T: Mul<T, Output = T> + Copy,

Source§

fn mul(self, other: T) -> Self::Output

Matrix3 * T = Matrix3

§Examples
use feo_math::linear_algebra::vector3::Vector3;
use feo_math::linear_algebra::matrix3::Matrix3;
let mat = Matrix3::new(
    [1, 2, 3],
    [2, 3, 1],
    [3, 1, 2]
);
let val = 2;
let expected = Matrix3::new(
    [2, 4, 6],
    [4, 6, 2],
    [6, 2, 4] 
);
assert_eq!(mat * val, expected);
Source§

type Output = Matrix3<T>

The resulting type after applying the * operator.
Source§

impl<T> Mul<Vector3<T>> for Matrix3<T>
where T: Add<T, Output = T> + Mul<T, Output = T> + Copy,

Source§

fn mul(self, rhs: Vector3<T>) -> Self::Output

Matrix * Vector3 = Vector3

[r0c0, r0c1, r0c2]   [x]   [x']
[r1c0, r1c1, r1c2] * [y] = [y']
[r2c0, r2c1, r2c2]   [z]   [z']
§Examples
use feo_math::linear_algebra::vector3::Vector3;
use feo_math::linear_algebra::matrix3::Matrix3;
let mat = Matrix3::new(
    [3, 2, 1],
    [1, 3, 2],
    [2, 1, 3]
);
let vec = Vector3::new(1, 3, 2);
assert_eq!(mat * vec, Vector3::new(11, 14, 11));
Source§

type Output = Vector3<T>

The resulting type after applying the * operator.
Source§

impl<T> Mul for Matrix3<T>
where T: Add<T, Output = T> + Mul<T, Output = T> + Copy,

Source§

fn mul(self, rhs: Self) -> Self::Output

Matrix3 * Matrix3 = Matrix3

§Examples
use feo_math::linear_algebra::vector3::Vector3;
use feo_math::linear_algebra::matrix3::Matrix3;
let mat0 = Matrix3::new(
    [4, 5, 6],
    [6, 4, 5],
    [5, 6, 4]
);
let mat1 = Matrix3::new(
    [1, 2, 3],
    [2, 3, 1],
    [2, 1, 2]
);
let expected = Matrix3::new(
    [26, 29, 29],
    [24, 29, 32],
    [25, 32, 29] 
);
assert_eq!(mat0 * mat1, expected);
Source§

type Output = Matrix3<T>

The resulting type after applying the * operator.
Source§

impl<T> Neg for Matrix3<T>
where T: Neg<Output = T> + Copy,

Source§

fn neg(self) -> Self::Output

-Matrix3 = Matrix3

§Examples
use feo_math::linear_algebra::matrix3::Matrix3;
let mat = Matrix3::new(
    [1, 2, 3],
    [2, 3, 1],
    [3, 1, 2]
);
let expected = Matrix3::new(
    [-1, -2, -3],
    [-2, -3, -1],
    [-3, -1, -2]
);
assert_eq!(-mat, expected);
Source§

type Output = Matrix3<T>

The resulting type after applying the - operator.
Source§

impl<T> One for Matrix3<T>
where T: Zero + One,

Source§

const ONE: Self

The identity matrix

Source§

impl<T: PartialEq> PartialEq for Matrix3<T>

Source§

fn eq(&self, other: &Matrix3<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Rem<T> for Matrix3<T>
where T: Rem<T, Output = T> + Copy,

Source§

fn rem(self, rhs: T) -> Self::Output

Matrix3 % T = Matrix3

§Examples
use feo_math::linear_algebra::vector3::Vector3;
use feo_math::linear_algebra::matrix3::Matrix3;
let mat = Matrix3::new(
    [1, 2, 3],
    [2, 3, 1],
    [3, 1, 2]
);
let val = 2;
let expected = Matrix3::new(
    [1, 0, 1],
    [0, 1, 1],
    [1, 1, 0]
);
assert_eq!(mat % val, expected);
use feo_math::linear_algebra::vector3::Vector3;
use feo_math::linear_algebra::matrix3::Matrix3;
let mat = Matrix3::new(
    [1, 2, 3],
    [2, 3, 1],
    [3, 1, 2]
);
mat % 0;
Source§

type Output = Matrix3<T>

The resulting type after applying the % operator.
Source§

impl<T> Rem for Matrix3<T>
where T: Rem<T, Output = T> + Copy,

Source§

fn rem(self, rhs: Self) -> Self::Output

Matrix3 % Matrix3 = Matrix3 Finds the remainder after an ELEMENT WISE division

§Examples
use feo_math::linear_algebra::vector3::Vector3;
use feo_math::linear_algebra::matrix3::Matrix3;
let mat0 = Matrix3::new(
    [4, 5, 6],
    [6, 4, 5],
    [5, 6, 4]
);
let mat1 = Matrix3::new(
    [1, 2, 3],
    [2, 3, 1],
    [3, 1, 2]
);
let expected = Matrix3::new(
    [0, 1, 0],
    [0, 1, 0],
    [2, 0, 0] 
);
assert_eq!(mat0 % mat1, expected);
Source§

type Output = Matrix3<T>

The resulting type after applying the % operator.
Source§

impl<T> SignOps for Matrix3<T>

Source§

fn ptcopysign(self, _sign: Self) -> Self

Source§

fn ptsignum(self) -> i8

Source§

fn abs(self) -> Self

Source§

impl<T> Sub<T> for Matrix3<T>
where T: Sub<T, Output = T> + Copy,

Source§

fn sub(self, rhs: T) -> Self::Output

Matrix3 - T = Matrix3

§Examples
use feo_math::linear_algebra::vector3::Vector3;
use feo_math::linear_algebra::matrix3::Matrix3;
let mat = Matrix3::new(
    [1, 2, 3],
    [2, 3, 1],
    [3, 1, 2]
);
let val = 2;
let expected = Matrix3::new(
    [-1,  0,  1],
    [ 0,  1, -1],
    [ 1, -1,  0]
);
assert_eq!(mat - val, expected);
Source§

type Output = Matrix3<T>

The resulting type after applying the - operator.
Source§

impl<T> Sub for Matrix3<T>
where T: Sub<T, Output = T> + Copy,

Source§

fn sub(self, rhs: Self) -> Self::Output

Matrix3 - Matrix3 = Matrix3

§Examples
use feo_math::linear_algebra::vector3::Vector3;
use feo_math::linear_algebra::matrix3::Matrix3;
let mat0 = Matrix3::new(
    [4, 5, 6],
    [6, 4, 5],
    [5, 6, 4]
);
let mat1 = Matrix3::new(
    [1, 2, 3],
    [2, 3, 1],
    [3, 1, 2]
);
let expected = Matrix3::new(
    [3, 3, 3],
    [4, 1, 4],
    [2, 5, 2] 
);
assert_eq!(mat0 - mat1, expected);
Source§

type Output = Matrix3<T>

The resulting type after applying the - operator.
Source§

impl<T> Two for Matrix3<T>
where T: Zero + Two,

Source§

const TWO: Self

The identity matrix * 2

Source§

impl<T> Zero for Matrix3<T>
where T: Zero + Copy,

Source§

const ZERO: Self

Source§

impl<T> Construct<T> for Matrix3<T>
where T: Construct<T>,

Source§

impl<T: Copy> Copy for Matrix3<T>

Source§

impl<T> SqMatrix<T, Vector3<T>> for Matrix3<T>
where T: Construct<T>,

Source§

impl<T> StructuralPartialEq for Matrix3<T>

Auto Trait Implementations§

§

impl<T> Freeze for Matrix3<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Matrix3<T>
where T: RefUnwindSafe,

§

impl<T> Send for Matrix3<T>
where T: Send,

§

impl<T> Sync for Matrix3<T>
where T: Sync,

§

impl<T> Unpin for Matrix3<T>
where T: Unpin,

§

impl<T> UnwindSafe for Matrix3<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, A> Typed<T> for A
where T: Construct<A>,