#[repr(C)]pub struct Mat4 {
pub cols: [Vec4; 4],
}Expand description
A 4x4 column-major matrix.
The matrix is stored in column-major order for GPU compatibility.
Columns are accessed as m.cols[column_index].
Fields§
§cols: [Vec4; 4]Matrix columns.
Implementations§
Source§impl Mat4
impl Mat4
Sourcepub const fn from_cols(c0: Vec4, c1: Vec4, c2: Vec4, c3: Vec4) -> Self
pub const fn from_cols(c0: Vec4, c1: Vec4, c2: Vec4, c3: Vec4) -> Self
Creates a matrix from column vectors.
Sourcepub fn from_rows(rows: [[Float; 4]; 4]) -> Self
pub fn from_rows(rows: [[Float; 4]; 4]) -> Self
Creates a matrix from row-major array (converts to column-major).
Sourcepub fn from_cols_array(arr: [Float; 16]) -> Self
pub fn from_cols_array(arr: [Float; 16]) -> Self
Creates a matrix from a flat column-major array.
Sourcepub fn to_cols_array(self) -> [Float; 16]
pub fn to_cols_array(self) -> [Float; 16]
Converts to a flat column-major array.
Sourcepub fn from_diagonal(diag: Vec4) -> Self
pub fn from_diagonal(diag: Vec4) -> Self
Creates a diagonal matrix.
Sourcepub fn from_scale(scale: Vec3) -> Self
pub fn from_scale(scale: Vec3) -> Self
Creates a scaling matrix.
Sourcepub fn from_translation(translation: Vec3) -> Self
pub fn from_translation(translation: Vec3) -> Self
Creates a translation matrix.
Sourcepub fn from_rotation_x(angle: Float) -> Self
pub fn from_rotation_x(angle: Float) -> Self
Creates a rotation matrix around the X axis.
Sourcepub fn from_rotation_y(angle: Float) -> Self
pub fn from_rotation_y(angle: Float) -> Self
Creates a rotation matrix around the Y axis.
Sourcepub fn from_rotation_z(angle: Float) -> Self
pub fn from_rotation_z(angle: Float) -> Self
Creates a rotation matrix around the Z axis.
Sourcepub fn from_axis_angle(axis: Vec3, angle: Float) -> Self
pub fn from_axis_angle(axis: Vec3, angle: Float) -> Self
Creates a rotation matrix around an arbitrary axis.
Sourcepub fn look_at_rh(eye: Vec3, target: Vec3, up: Vec3) -> Self
pub fn look_at_rh(eye: Vec3, target: Vec3, up: Vec3) -> Self
Creates a look-at view matrix (right-handed).
Sourcepub fn look_at_lh(eye: Vec3, target: Vec3, up: Vec3) -> Self
pub fn look_at_lh(eye: Vec3, target: Vec3, up: Vec3) -> Self
Creates a look-at view matrix (left-handed).
Sourcepub fn perspective_rh(
fov_y: Float,
aspect: Float,
near: Float,
far: Float,
) -> Self
pub fn perspective_rh( fov_y: Float, aspect: Float, near: Float, far: Float, ) -> Self
Creates a perspective projection matrix (right-handed, Vulkan clip space).
fov_y: Vertical field of view in radiansaspect: Aspect ratio (width / height)near: Near clipping planefar: Far clipping plane
Sourcepub fn orthographic_rh(
left: Float,
right: Float,
bottom: Float,
top: Float,
near: Float,
far: Float,
) -> Self
pub fn orthographic_rh( left: Float, right: Float, bottom: Float, top: Float, near: Float, far: Float, ) -> Self
Creates an orthographic projection matrix (right-handed).
Sourcepub fn determinant(self) -> Float
pub fn determinant(self) -> Float
Computes the determinant.
Sourcepub fn try_inverse(self) -> Option<Self>
pub fn try_inverse(self) -> Option<Self>
Returns the inverse of this matrix, or None if not invertible.
Sourcepub fn transform_vec4(self, v: Vec4) -> Vec4
pub fn transform_vec4(self, v: Vec4) -> Vec4
Transforms a Vec4 by this matrix.
Sourcepub fn transform_point(self, p: Vec3) -> Vec3
pub fn transform_point(self, p: Vec3) -> Vec3
Transforms a point (Vec3 with w=1).
Sourcepub fn transform_vector(self, v: Vec3) -> Vec3
pub fn transform_vector(self, v: Vec3) -> Vec3
Transforms a direction vector (Vec3 with w=0).
Trait Implementations§
impl 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§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more