Skip to main content

Mat4

Struct Mat4 

Source
pub struct Mat4 {
    pub data: [f32; 16],
}
Expand description

A 4x4 matrix. Data and operations are column-major.

Fields§

§data: [f32; 16]

Implementations§

Source§

impl Mat4

Source

pub fn new(data: [f32; 16]) -> Self

Source

pub fn new_perspective_lh( fov_y: f32, aspect_ratio: f32, z_near: f32, z_far: f32, ) -> Self

Creates a left-hand perspective projection matrix with 0-1 depth range. Field of view is in radians. Aspect is width / height. https://docs.rs/glam/latest/src/glam/$f/sse2/mat4.rs.html#818-830

Source

pub fn new_rotation(val: Vec3) -> Self

https://learnopengl.com/Getting-started/Transformations

Source

pub fn new_scaler(scale: f32) -> Self

Source

pub fn new_scaler_partial(scale: Vec3) -> Self

Source

pub fn new_translation(val: Vec3) -> Self

Create a translation matrix. Note that the matrix is 4x4, but it takes len-3 vectors - this is so we can compose it with other 4x4 matrices.

Source

pub const fn new_identity() -> Self

Source

pub fn determinant(&self) -> f32

Calculate the matrix’s determinant.

Source

pub fn transpose(&self) -> Self

Transpose the matrix

Source

pub fn to_cols(&self) -> (Vec4, Vec4, Vec4, Vec4)

Returns cols: x, y, z, w

Source

pub fn inverse(&self) -> Option<Self>

Source§

impl Mat4

Source

pub fn to_bytes(&self) -> [u8; 64]

Trait Implementations§

Source§

impl Clone for Mat4

Source§

fn clone(&self) -> Mat4

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 Mat4

Source§

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

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

impl Display for Mat4

Available on crate feature std only.
Source§

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

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

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

Source§

fn from(m: &Mat4) -> Self

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.
Source§

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

Source§

fn from(m: Mat4) -> Self

Converts to this type from the input type.
Source§

impl From<Mat4> for Mat4

Source§

fn from(other: Mat4) -> Self

Converts to this type from the input type.
Source§

impl From<Mat4> for Mat4

Source§

fn from(other: Mat4) -> Self

Converts to this type from the input type.
Source§

impl Mul<Vec4> for Mat4

Source§

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

Source§

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 Mul for Mat4

Source§

type Output = Mat4

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more

Auto Trait Implementations§

§

impl Freeze for Mat4

§

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 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.