Struct euler::Mat4

source ·
#[repr(C)]
pub struct Mat4 {
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

Single-precision 2x2 column major 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 Mat4

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 identity() -> Self

Identity 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§

impl Mat4

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) -> Mat4

Computes the matrix inverse.

Panics

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

Examples found in repository?
examples/unproject.rs (line 8)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
fn unproject_single_precision(ndc: euler::Vec2) -> euler::Vec3 {
    let projection = mat4!();
    let inverse_projection = projection.inverse();
    let eye = inverse_projection * vec4!(ndc, -1.0, 1.0);
    let view = euler::Trs::new(
        vec3!(1, 0, -1),
        quat!(1, 0, 0; f32::consts::PI / 2.0),
        vec3!(1.0),
    )
    .matrix();
    let inverse_view = view.inverse();
    let world = inverse_view * vec4!(eye.xy(), -1.0, 0.0);
    let ray = world.xyz().normalize();
    ray
}
source

pub fn transpose(self) -> Mat4

Returns the matrix transpose.

source

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

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

Trait Implementations§

source§

impl Add<Mat4> for Mat4

§

type Output = Mat4

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl ApproxEq for Mat4

§

type Epsilon = <Matrix4<f32> as ApproxEq>::Epsilon

Used for specifying relative comparisons.
source§

fn default_epsilon() -> Self::Epsilon

The default tolerance to use when testing values that are close together. Read more
source§

fn default_max_relative() -> Self::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
source§

fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
source§

fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.
source§

fn relative_ne( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

The inverse of ApproxEq::relative_eq.
source§

fn ulps_ne(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of ApproxEq::ulps_eq.
source§

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

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 Mat4

source§

fn clone(&self) -> Mat4

Returns a copy 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 Mat4

source§

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

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

impl Default for Mat4

source§

fn default() -> Self

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

impl Display for Mat4

source§

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

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

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

source§

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

Converts to this type from the input type.
source§

impl From<DMat2> for Mat4

source§

fn from(arg: DMat2) -> Self

Converts to this type from the input type.
source§

impl From<DMat3> for Mat4

source§

fn from(arg: DMat3) -> Self

Converts to this type from the input type.
source§

impl From<DMat4> for Mat4

source§

fn from(arg: DMat4) -> Self

Converts to this type from the input type.
source§

impl From<Mat2> for Mat4

source§

fn from(arg: Mat2) -> Self

Converts to this type from the input type.
source§

impl From<Mat3> for Mat4

source§

fn from(arg: Mat3) -> Self

Converts to this type from the input type.
source§

impl From<Mat4> for DMat2

source§

fn from(arg: Mat4) -> Self

Converts to this type from the input type.
source§

impl From<Mat4> for DMat3

source§

fn from(arg: Mat4) -> Self

Converts to this type from the input type.
source§

impl From<Mat4> for DMat4

source§

fn from(arg: Mat4) -> Self

Converts to this type from the input type.
source§

impl From<Mat4> for Mat2

source§

fn from(arg: Mat4) -> Self

Converts to this type from the input type.
source§

impl From<Mat4> for Mat3

source§

fn from(arg: Mat4) -> Self

Converts to this type from the input type.
source§

impl From<f32> for Mat4

source§

fn from(arg: f32) -> Self

Converts to this type from the input type.
source§

impl From<f64> for Mat4

source§

fn from(arg: f64) -> Self

Converts to this type from the input type.
source§

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

source§

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

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

impl Mul<Mat4> for Mat4

§

type Output = Mat4

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<Mat4> for f32

§

type Output = Mat4

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<'a> Mul<Vec4> for &'a Mat4

§

type Output = Vec4

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<Vec4> for Mat4

§

type Output = Vec4

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<f32> for Mat4

§

type Output = Mat4

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl PartialEq<Mat4> for Mat4

source§

fn eq(&self, other: &Mat4) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Sub<Mat4> for Mat4

§

type Output = Mat4

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl Copy for Mat4

source§

impl StructuralPartialEq for Mat4

Auto Trait Implementations§

§

impl RefUnwindSafe for Mat4

§

impl Send for Mat4

§

impl Sync for Mat4

§

impl Unpin for Mat4

§

impl UnwindSafe for Mat4

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.