#[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: Vec4Implementations§
Source§impl Mat4
impl Mat4
pub const IDENTITY: Mat4
pub const ZERO: Mat4
pub const NAN: Mat4
pub const fn from_cols( x_axis: Vec4, y_axis: Vec4, z_axis: Vec4, w_axis: Vec4, ) -> Mat4
pub const fn from_cols_array(v: &[f32; 16]) -> Mat4
pub const fn from_cols_array_2d(v: &[[f32; 4]; 4]) -> Mat4
pub const fn to_cols_array(self) -> [f32; 16]
pub const fn to_cols_array_2d(self) -> [[f32; 4]; 4]
pub fn col(self, index: usize) -> Vec4
pub fn row(self, index: usize) -> Vec4
pub fn transpose(self) -> Mat4
pub const fn from_translation(v: Vec3) -> Mat4
pub const fn from_scale(v: Vec3) -> Mat4
pub const fn from_diagonal(v: Vec4) -> Mat4
Sourcepub fn from_quat(rotation: Quat) -> Mat4
pub fn from_quat(rotation: Quat) -> Mat4
The quaternion is normalized to avoid embedding accidental scale.
pub fn from_axis_angle(axis: Vec3, angle: f32) -> Mat4
pub fn from_rotation_x(angle: f32) -> Mat4
pub fn from_rotation_y(angle: f32) -> Mat4
pub fn from_rotation_z(angle: f32) -> Mat4
pub fn from_rotation_translation(rotation: Quat, translation: Vec3) -> Mat4
pub fn from_scale_rotation_translation( scale: Vec3, rotation: Quat, translation: Vec3, ) -> Mat4
pub fn transform_point3(self, v: Vec3) -> Vec3
pub fn transform_vector3(self, v: Vec3) -> Vec3
pub fn project_point3(self, v: Vec3) -> Vec3
pub fn mul_vec4(self, v: Vec4) -> Vec4
pub fn mul_mat4(self, rhs: Mat4) -> Mat4
pub fn is_finite(self) -> bool
pub fn is_nan(self) -> bool
pub fn abs_diff_eq(self, rhs: Mat4, tolerance: f32) -> bool
Sourcepub fn determinant(self) -> f32
pub fn determinant(self) -> f32
Partial-pivot Gaussian elimination with f64 intermediates.
Sourcepub fn try_inverse(self) -> Option<Mat4>
pub fn try_inverse(self) -> Option<Mat4>
Returns None for singular/non-finite matrices or inverses outside f32 range.
pub fn inverse(self) -> Mat4
Sourcepub fn look_at_rh(eye: Vec3, target: Vec3, up: Vec3) -> Mat4
pub fn look_at_rh(eye: Vec3, target: Vec3, up: Vec3) -> Mat4
Right-handed view: the camera looks along its negative Z axis.
pub fn look_to_rh(eye: Vec3, direction: Vec3, up: Vec3) -> Mat4
pub fn look_at_lh(eye: Vec3, target: Vec3, up: Vec3) -> Mat4
pub fn look_to_lh(eye: Vec3, direction: Vec3, up: Vec3) -> Mat4
Sourcepub fn perspective_rh_gl(fov_y: f32, aspect: f32, near: f32, far: f32) -> Mat4
pub fn perspective_rh_gl(fov_y: f32, aspect: f32, near: f32, far: f32) -> Mat4
Right-handed perspective with OpenGL depth [-1, 1].
Sourcepub fn perspective_rh(fov_y: f32, aspect: f32, near: f32, far: f32) -> Mat4
pub fn perspective_rh(fov_y: f32, aspect: f32, near: f32, far: f32) -> Mat4
Right-handed perspective with WebGPU/Vulkan/Metal depth [0, 1].
pub fn perspective_lh(fov_y: f32, aspect: f32, near: f32, far: f32) -> Mat4
pub fn perspective_infinite_rh(fov_y: f32, aspect: f32, near: f32) -> Mat4
pub fn perspective_infinite_reverse_rh( fov_y: f32, aspect: f32, near: f32, ) -> Mat4
pub fn orthographic_rh_gl( left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32, ) -> Mat4
pub fn orthographic_rh( left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32, ) -> Mat4
pub fn orthographic_lh( left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32, ) -> Mat4
Sourcepub fn try_to_scale_rotation_translation(self) -> Option<(Vec3, Quat, Vec3)>
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.
pub fn to_scale_rotation_translation(self) -> (Vec3, Quat, Vec3)
Trait Implementations§
Source§impl MulAssign for Mat4
impl MulAssign for Mat4
Source§fn mul_assign(&mut self, rhs: Mat4)
fn mul_assign(&mut self, rhs: Mat4)
Performs the
*= operation. Read moreimpl Copy for Mat4
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more