Struct Mat3

Source
#[repr(C)]
pub struct Mat3<T> { pub a11: T, pub a12: T, pub a13: T, pub a21: T, pub a22: T, pub a23: T, pub a31: T, pub a32: T, pub a33: T, }
Expand description

3D transformation matrix.

Each field aij represents the i-th row and j-th column of the matrix.

Row-major storage with column-major semantics.

Stored in row-major order (fields appear in reading order), but interpreted as column-major: each column is a transformed basis vector, and matrices are applied to column vectors via mat * vec.

Fields§

§a11: T§a12: T§a13: T§a21: T§a22: T§a23: T§a31: T§a32: T§a33: T

Implementations§

Source§

impl<T> Mat3<T>

Source

pub const fn new( a11: T, a12: T, a13: T, a21: T, a22: T, a23: T, a31: T, a32: T, a33: T, ) -> Mat3<T>

Constructs a new matrix from components.

Source§

impl<T: Zero> Mat3<T>

Source

pub const ZERO: Mat3<T>

Zero matrix.

Source§

impl<T: Zero + One> Mat3<T>

Source

pub const IDENTITY: Mat3<T>

Identity matrix.

Source§

impl<T: Float> Mat3<T>

Source

pub fn scale(scale: Vec3<T>) -> Mat3<T>

Scaling matrix.

Source

pub fn rotate(axis: Vec3<T>, angle: Angle<T>) -> Mat3<T>

Rotation matrix around an axis.

Source§

impl<T> Mat3<T>

Source

pub fn mat2(self) -> Mat2<T>

Converts to a Mat2 matrix.

Source

pub fn transform3(self) -> Transform3<T>
where T: Zero,

Converts to a Transform3 matrix.

Source

pub fn translate(self, trans: Vec3<T>) -> Transform3<T>

Adds a translation to the matrix.

Source§

impl<T> Mat3<T>

Source

pub fn from_row_major(mat: [[T; 3]; 3]) -> Mat3<T>

Imports the matrix from a row-major layout.

Source

pub fn from_column_major(mat: [[T; 3]; 3]) -> Mat3<T>

Imports the matrix from a column-major layout.

Source

pub fn into_row_major(self) -> [[T; 3]; 3]

Exports the matrix as a row-major array.

Source

pub fn into_column_major(self) -> [[T; 3]; 3]

Exports the matrix as a column-major array.

Source§

impl<T> Mat3<T>

Source

pub fn compose(x: Vec3<T>, y: Vec3<T>, z: Vec3<T>) -> Mat3<T>

Composes the matrix from basis vectors.

Source

pub fn x(self) -> Vec3<T>

Gets the transformed X basis vector.

Source

pub fn y(self) -> Vec3<T>

Gets the transformed Y basis vector.

Source

pub fn z(self) -> Vec3<T>

Gets the transformed Z basis vector.

Source§

impl<T: Scalar> Mat3<T>

Source

pub fn det(self) -> T

Computes the determinant.

Source

pub fn trace(self) -> T

Computes the trace.

Source

pub fn flat_norm_sqr(self) -> T

Computes the squared Frobenius norm (sum of squares of all matrix elements).

This measure is useful for quickly checking matrix magnitude or comparing matrices without the cost of a square root operation.

To check if a matrix is effectively zero, test if flat_norm_sqr() is below a small epsilon threshold.

Source

pub fn try_invert(self) -> Option<Mat3<T>>
where T: Float,

Source

pub fn inverse(self) -> Mat3<T>
where T: Float,

Computes the inverse matrix.

Returns the zero matrix if the determinant is near zero.

Source

pub fn transpose(self) -> Mat3<T>

Returns the transposed matrix.

Source

pub fn adjugate(self) -> Mat3<T>

Computes the adjugate matrix.

Source

pub fn lerp(self, rhs: Mat3<T>, t: T) -> Mat3<T>
where T: Float,

Linear interpolation between the matrix elements.

Trait Implementations§

Source§

impl<T: Clone> Clone for Mat3<T>

Source§

fn clone(&self) -> Mat3<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> Debug for Mat3<T>

Source§

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

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

impl<T: Default> Default for Mat3<T>

Source§

fn default() -> Mat3<T>

Returns the “default value” for a type. Read more
Source§

impl<T: Display> Display for Mat3<T>

Source§

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

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

impl<T: Zero + One> From<Mat3<T>> for Mat4<T>

Source§

fn from(mat: Mat3<T>) -> Mat4<T>

Converts to this type from the input type.
Source§

impl<T: Zero + One> From<Transform2<T>> for Mat3<T>

Source§

fn from(mat: Transform2<T>) -> Mat3<T>

Converts to this type from the input type.
Source§

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

Source§

type Output = Mat3<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Mat3<T>) -> Mat3<T>

Performs the * operation. Read more
Source§

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

Source§

type Output = Mat3<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Mat3<T>) -> Mat3<T>

Performs the * operation. Read more
Source§

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

Source§

type Output = Mat3<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &T) -> Mat3<T>

Performs the * operation. Read more
Source§

impl<T> Mul<&T> for Mat3<T>
where Mat3<T>: Mul<T, Output = Mat3<T>>, T: Copy,

Source§

type Output = Mat3<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &T) -> Mat3<T>

Performs the * operation. Read more
Source§

impl<T> Mul<&Vec3<T>> for &Mat3<T>
where Mat3<T>: Copy + Mul<Vec3<T>, Output = Vec3<T>>, Vec3<T>: Copy,

Source§

type Output = Vec3<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Vec3<T>) -> Vec3<T>

Performs the * operation. Read more
Source§

impl<T> Mul<&Vec3<T>> for Mat3<T>
where Mat3<T>: Mul<Vec3<T>, Output = Vec3<T>>, Vec3<T>: Copy,

Source§

type Output = Vec3<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Vec3<T>) -> Vec3<T>

Performs the * operation. Read more
Source§

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

Source§

type Output = Mat3<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Mat3<T>) -> Mat3<T>

Performs the * operation. Read more
Source§

impl<T: Copy + Add<Output = T> + Mul<Output = T>> Mul<Mat3<T>> for Transform3<T>

Source§

type Output = Transform3<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Mat3<T>) -> Transform3<T>

Performs the * operation. Read more
Source§

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

Source§

type Output = Mat3<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Mat3<T>

Performs the * operation. Read more
Source§

impl<T: Copy + Mul<Output = T>> Mul<T> for Mat3<T>

Source§

type Output = Mat3<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Mat3<T>

Performs the * operation. Read more
Source§

impl<T: Copy + Add<Output = T> + Mul<Output = T>> Mul<Transform2<T>> for Mat3<T>

Source§

type Output = Mat3<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Transform2<T>) -> Mat3<T>

Performs the * operation. Read more
Source§

impl<T> Mul<Vec3<T>> for &Mat3<T>
where Mat3<T>: Copy + Mul<Vec3<T>, Output = Vec3<T>>,

Source§

type Output = Vec3<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec3<T>) -> Vec3<T>

Performs the * operation. Read more
Source§

impl<T: Copy + Add<Output = T> + Mul<Output = T>> Mul<Vec3<T>> for Mat3<T>

Source§

type Output = Vec3<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec3<T>) -> Vec3<T>

Performs the * operation. Read more
Source§

impl<T: Copy + Add<Output = T> + Mul<Output = T>> Mul for Mat3<T>

Source§

type Output = Mat3<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Mat3<T>) -> Mat3<T>

Performs the * operation. Read more
Source§

impl<T> MulAssign<&Mat3<T>> for Mat3<T>
where Mat3<T>: MulAssign<Mat3<T>> + Copy,

Source§

fn mul_assign(&mut self, rhs: &Mat3<T>)

Performs the *= operation. Read more
Source§

impl<T> MulAssign<&T> for Mat3<T>
where Mat3<T>: MulAssign<T>, T: Copy,

Source§

fn mul_assign(&mut self, rhs: &T)

Performs the *= operation. Read more
Source§

impl<T: Copy + Add<Output = T> + Mul<Output = T>> MulAssign<Mat3<T>> for Transform3<T>

Source§

fn mul_assign(&mut self, rhs: Mat3<T>)

Performs the *= operation. Read more
Source§

impl<T: Copy + MulAssign> MulAssign<T> for Mat3<T>

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl<T: Copy + Add<Output = T> + Mul<Output = T>> MulAssign<Transform2<T>> for Mat3<T>

Source§

fn mul_assign(&mut self, rhs: Transform2<T>)

Performs the *= operation. Read more
Source§

impl<T: Copy + Add<Output = T> + Mul<Output = T>> MulAssign for Mat3<T>

Source§

fn mul_assign(&mut self, rhs: Mat3<T>)

Performs the *= operation. Read more
Source§

impl<T: PartialEq> PartialEq for Mat3<T>

Source§

fn eq(&self, other: &Mat3<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: Copy> Copy for Mat3<T>

Source§

impl<T> StructuralPartialEq for Mat3<T>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for Mat3<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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.