Matrix

Struct Matrix 

Source
#[repr(C)]
pub struct Matrix {
Show 16 fields pub m00: f32, pub m01: f32, pub m02: f32, pub m03: f32, pub m10: f32, pub m11: f32, pub m12: f32, pub m13: f32, pub m20: f32, pub m21: f32, pub m22: f32, pub m23: f32, pub m30: f32, pub m31: f32, pub m32: f32, pub m33: f32,
}
Expand description

4x4 Matrix.

Fields§

§m00: f32§m01: f32§m02: f32§m03: f32§m10: f32§m11: f32§m12: f32§m13: f32§m20: f32§m21: f32§m22: f32§m23: f32§m30: f32§m31: f32§m32: f32§m33: f32

Implementations§

Source§

impl Matrix

Source

pub fn srt(self, scale: Vector, rotate: Rotation, translate: Vector) -> Self

Scale, then rotate Quaternion (axis, angle), then translate.

Source

pub fn rt(self, rotate: Rotation, translate: Vector) -> Self

Rotate Quaternion (axis, angle), then translate.

Source

pub fn st(self, scale: Vector, translate: Vector) -> Self

Scale, then translate.

Source

pub fn t(self, translate: Vector) -> Self

Translate.

Source

pub fn s(self, scale: Vector) -> Self

Scale.

Source

pub fn r(self, rotation: Rotation) -> Self

Rotate Quaternion (axis, angle).

Source

pub fn m(self, matrix: Self) -> Self

Multiply by a custom matrix

Source

pub fn new( m00: f32, m01: f32, m02: f32, m03: f32, m10: f32, m11: f32, m12: f32, m13: f32, m20: f32, m21: f32, m22: f32, m23: f32, m30: f32, m31: f32, m32: f32, m33: f32, ) -> Self

Full constructor.

Source

pub fn diagonal(di: f32) -> Self

Diagonal constructor.

Source

pub fn tridiagonal(lo: f32, di: f32, up: f32) -> Self

Tri-diagonal constructor.

Source

pub fn orthographic_projection( left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32, ) -> Self

Orthographic projection matrix constructor.

Source

pub fn finite_perspective_projection( fovy: f32, aspect: f32, near: f32, far: f32, ) -> Self

Finite perspective projection matrix constructor.

Source

pub fn determinant(self) -> f32

Computes the matrix determinant.

Source

pub fn trace(self) -> f32

Computes the matrix trace.

Source

pub fn inverse(self) -> Matrix

Computes the matrix inverse.

§Panics

Panics if the matrix has no inverse (i.e. has zero determinant).

Source

pub fn transpose(self) -> Matrix

Returns the matrix transpose.

Source

pub fn try_invert(self) -> Option<Matrix>

Attempts to compute the matrix inverse, returning None if the matrix is non-invertible (i.e. has zero determinant).

Trait Implementations§

Source§

impl Add for Matrix

Source§

type Output = Matrix

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AsRef<[[f32; 4]; 4]> for Matrix

Source§

fn as_ref(&self) -> &[[f32; 4]; 4]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Matrix

Source§

fn clone(&self) -> Matrix

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 Debug for Matrix

Source§

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

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

impl Default for Matrix

Source§

fn default() -> Self

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

impl Display for Matrix

Source§

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

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

impl From<[[f32; 4]; 4]> for Matrix

Source§

fn from(array: [[f32; 4]; 4]) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Matrix

Source§

fn from(arg: f32) -> Self

Converts to this type from the input type.
Source§

impl Into<[[f32; 4]; 4]> for Matrix

Source§

fn into(self) -> [[f32; 4]; 4]

Converts this type into the (usually inferred) input type.
Source§

impl Into<[f32; 16]> for Matrix

Source§

fn into(self) -> [f32; 16]

Converts this type into the (usually inferred) input type.
Source§

impl<'a> Mul<(Vector, f32)> for &'a Matrix

Source§

type Output = Vector

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<(Vector, f32)> for Matrix

Source§

type Output = Vector

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<Matrix> for f32

Source§

type Output = Matrix

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<f32> for Matrix

Source§

type Output = Matrix

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul for Matrix

Source§

type Output = Matrix

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl PartialEq for Matrix

Source§

fn eq(&self, other: &Matrix) -> 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 Sub for Matrix

Source§

type Output = Matrix

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Copy for Matrix

Source§

impl StructuralPartialEq for Matrix

Auto Trait Implementations§

§

impl Freeze for Matrix

§

impl RefUnwindSafe for Matrix

§

impl Send for Matrix

§

impl Sync for Matrix

§

impl Unpin for Matrix

§

impl UnwindSafe for Matrix

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.