Struct Mat4

Source
#[repr(C)]
pub struct Mat4 { pub x_axis: Vec4, pub y_axis: Vec4, pub z_axis: Vec4, pub w_axis: Vec4, }
Expand description

Column-major 4x4 matrix acting on column vectors: translation * rotation * scale.

Fields§

§x_axis: Vec4§y_axis: Vec4§z_axis: Vec4§w_axis: Vec4

Implementations§

Source§

impl Mat4

Source

pub const IDENTITY: Mat4

Source

pub const ZERO: Mat4

Source

pub const NAN: Mat4

Source

pub const fn from_cols( x_axis: Vec4, y_axis: Vec4, z_axis: Vec4, w_axis: Vec4, ) -> Mat4

Source

pub const fn from_cols_array(v: &[f32; 16]) -> Mat4

Source

pub const fn from_cols_array_2d(v: &[[f32; 4]; 4]) -> Mat4

Source

pub const fn to_cols_array(self) -> [f32; 16]

Source

pub const fn to_cols_array_2d(self) -> [[f32; 4]; 4]

Source

pub fn col(self, index: usize) -> Vec4

Source

pub fn row(self, index: usize) -> Vec4

Source

pub fn transpose(self) -> Mat4

Source

pub const fn from_translation(v: Vec3) -> Mat4

Source

pub const fn from_scale(v: Vec3) -> Mat4

Source

pub const fn from_diagonal(v: Vec4) -> Mat4

Source

pub fn from_quat(rotation: Quat) -> Mat4

The quaternion is normalized to avoid embedding accidental scale.

Source

pub fn from_axis_angle(axis: Vec3, angle: f32) -> Mat4

Source

pub fn from_rotation_x(angle: f32) -> Mat4

Source

pub fn from_rotation_y(angle: f32) -> Mat4

Source

pub fn from_rotation_z(angle: f32) -> Mat4

Source

pub fn from_rotation_translation(rotation: Quat, translation: Vec3) -> Mat4

Source

pub fn from_scale_rotation_translation( scale: Vec3, rotation: Quat, translation: Vec3, ) -> Mat4

Source

pub fn transform_point3(self, v: Vec3) -> Vec3

Source

pub fn transform_vector3(self, v: Vec3) -> Vec3

Source

pub fn project_point3(self, v: Vec3) -> Vec3

Source

pub fn mul_vec4(self, v: Vec4) -> Vec4

Source

pub fn mul_mat4(self, rhs: Mat4) -> Mat4

Source

pub fn is_finite(self) -> bool

Source

pub fn is_nan(self) -> bool

Source

pub fn abs_diff_eq(self, rhs: Mat4, tolerance: f32) -> bool

Source

pub fn determinant(self) -> f32

Partial-pivot Gaussian elimination with f64 intermediates.

Source

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

Returns None for singular/non-finite matrices or inverses outside f32 range.

Source

pub fn inverse(self) -> Mat4

Source

pub fn look_at_rh(eye: Vec3, target: Vec3, up: Vec3) -> Mat4

Right-handed view: the camera looks along its negative Z axis.

Source

pub fn look_to_rh(eye: Vec3, direction: Vec3, up: Vec3) -> Mat4

Source

pub fn look_at_lh(eye: Vec3, target: Vec3, up: Vec3) -> Mat4

Source

pub fn look_to_lh(eye: Vec3, direction: Vec3, up: Vec3) -> Mat4

Source

pub fn perspective_rh_gl(fov_y: f32, aspect: f32, near: f32, far: f32) -> Mat4

Right-handed perspective with OpenGL depth [-1, 1].

Source

pub fn perspective_rh(fov_y: f32, aspect: f32, near: f32, far: f32) -> Mat4

Right-handed perspective with WebGPU/Vulkan/Metal depth [0, 1].

Source

pub fn perspective_lh(fov_y: f32, aspect: f32, near: f32, far: f32) -> Mat4

Source

pub fn perspective_infinite_rh(fov_y: f32, aspect: f32, near: f32) -> Mat4

Source

pub fn perspective_infinite_reverse_rh( fov_y: f32, aspect: f32, near: f32, ) -> Mat4

Source

pub fn orthographic_rh_gl( left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32, ) -> Mat4

Source

pub fn orthographic_rh( left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32, ) -> Mat4

Source

pub fn orthographic_lh( left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32, ) -> Mat4

Source

pub fn try_to_scale_rotation_translation(self) -> Option<(Vec3, Quat, Vec3)>

Extracts TRS from an affine matrix with orthogonal, nonzero scale axes. Shear and perspective are rejected rather than approximated.

Source

pub fn to_scale_rotation_translation(self) -> (Vec3, Quat, Vec3)

Trait Implementations§

Source§

impl Add for Mat4

Source§

type Output = Mat4

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
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<(), Error>

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

impl Default for Mat4

Source§

fn default() -> Mat4

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

impl Index<usize> for Mat4

Source§

type Output = Vec4

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Vec4

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<usize> for Mat4

Source§

fn index_mut(&mut self, index: usize) -> &mut Vec4

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl Mul<Vec4> for Mat4

Source§

type Output = Vec4

The resulting type after applying the * operator.
Source§

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

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

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

Performs the * operation. Read more
Source§

impl MulAssign for Mat4

Source§

fn mul_assign(&mut self, rhs: Mat4)

Performs the *= operation. Read more
Source§

impl PartialEq for Mat4

Source§

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

Source§

type Output = Mat4

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Copy for Mat4

Source§

impl StructuralPartialEq for Mat4

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