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>
impl<T> Matrix3<T>
pub fn new(row0: [T; 3], row1: [T; 3], row2: [T; 3]) -> Self
pub fn new_val( r0c0: T, r0c1: T, r0c2: T, r1c0: T, r1c1: T, r1c2: T, r2c0: T, r2c1: T, r2c2: T, ) -> Self
Sourcepub fn determinant(&self) -> T
pub fn determinant(&self) -> T
Sourcepub fn transpose(&self) -> Matrix3<T>where
T: Copy,
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);
Sourcepub fn eigen_value(&self) -> [Option<T>; 3]
pub fn eigen_value(&self) -> [Option<T>; 3]
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
pub fn eigen_vector(&self, eigen_value: T) -> Vector3<T>
Sourcepub fn inverse(&self) -> Self
pub fn inverse(&self) -> Self
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>
impl<T> Add<T> for Matrix3<T>
Source§fn add(self, rhs: T) -> Self::Output
fn add(self, rhs: T) -> Self::Output
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§impl<T> Add for Matrix3<T>
impl<T> Add for Matrix3<T>
Source§fn add(self, rhs: Self) -> Self::Output
fn add(self, rhs: Self) -> Self::Output
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§impl<T> Div<T> for Matrix3<T>
impl<T> Div<T> for Matrix3<T>
Source§fn div(self, rhs: T) -> Self::Output
fn div(self, rhs: T) -> Self::Output
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§impl<T> Div for Matrix3<T>
impl<T> Div for Matrix3<T>
Source§fn div(self, rhs: Self) -> Self::Output
fn div(self, rhs: Self) -> Self::Output
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§impl<T> F32Fmt for Matrix3<T>
impl<T> F32Fmt for Matrix3<T>
type F32Fmt = Matrix3<<T as F32Fmt>::F32Fmt>
fn intoF32Fmt(self) -> Self::F32Fmt
fn fromF32Fmt(f32_fmt: Self::F32Fmt) -> Self
fn sqrt(self) -> Self
fn cbrt(self) -> Self
fn f32_const_mul(self, constant: f32) -> Self
fn sin_mul(self, _mul_by: Self) -> Self
fn cos_mul(self, _mul_by: Self) -> Self
fn tan_mul(self, _mul_by: Self) -> Self
fn asin_mul(self, _mul_by: Self) -> Self
fn acos_mul(self, _mul_by: Self) -> Self
fn atan_mul(self, _mul_by: Self) -> Self
fn atan2_mul(self, _other: Self, _mul_by: Self) -> Self
fn sinh_mul(self, _mul_by: Self) -> Self
fn cosh_mul(self, _mul_by: Self) -> Self
fn tanh_mul(self, _mul_by: Self) -> Self
Source§impl<T> From<Matrix3<T>> for Quaternion<T>
impl<T> From<Matrix3<T>> for Quaternion<T>
Source§impl<T> From<Quaternion<T>> for Matrix3<T>
impl<T> From<Quaternion<T>> for Matrix3<T>
Source§fn from(other: Quaternion<T>) -> Matrix3<T>
fn from(other: Quaternion<T>) -> Matrix3<T>
Converts to this type from the input type.
Source§impl<T> Mul<T> for Matrix3<T>
impl<T> Mul<T> for Matrix3<T>
Source§fn mul(self, other: T) -> Self::Output
fn mul(self, other: T) -> Self::Output
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§impl<T> Mul<Vector3<T>> for Matrix3<T>
impl<T> Mul<Vector3<T>> for Matrix3<T>
Source§fn mul(self, rhs: Vector3<T>) -> Self::Output
fn mul(self, rhs: Vector3<T>) -> Self::Output
Matrix
[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§impl<T> Mul for Matrix3<T>
impl<T> Mul for Matrix3<T>
Source§fn mul(self, rhs: Self) -> Self::Output
fn mul(self, rhs: Self) -> Self::Output
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§impl<T> Neg for Matrix3<T>
impl<T> Neg for Matrix3<T>
Source§impl<T> Rem<T> for Matrix3<T>
impl<T> Rem<T> for Matrix3<T>
Source§fn rem(self, rhs: T) -> Self::Output
fn rem(self, rhs: T) -> Self::Output
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§impl<T> Rem for Matrix3<T>
impl<T> Rem for Matrix3<T>
Source§fn rem(self, rhs: Self) -> Self::Output
fn rem(self, rhs: Self) -> Self::Output
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(
[0, 1, 0],
[0, 1, 0],
[2, 0, 0]
);
assert_eq!(mat0 % mat1, expected);
Source§impl<T> Sub<T> for Matrix3<T>
impl<T> Sub<T> for Matrix3<T>
Source§fn sub(self, rhs: T) -> Self::Output
fn sub(self, rhs: T) -> Self::Output
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§impl<T> Sub for Matrix3<T>
impl<T> Sub for Matrix3<T>
Source§fn sub(self, rhs: Self) -> Self::Output
fn sub(self, rhs: Self) -> Self::Output
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);
impl<T> Construct<T> for Matrix3<T>where
T: Construct<T>,
impl<T: Copy> Copy for Matrix3<T>
impl<T> SqMatrix<T, Vector3<T>> for Matrix3<T>where
T: Construct<T>,
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> 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