pub struct Mat4 {
pub cols: [Vec4; 4],
}Expand description
A 4x4 column-major matrix.
Fields§
§cols: [Vec4; 4]Matrix columns.
Implementations§
Source§impl Mat4
impl Mat4
Sourcepub const fn from_cols(x: Vec4, y: Vec4, z: Vec4, w: Vec4) -> Self
pub const fn from_cols(x: Vec4, y: Vec4, z: Vec4, w: Vec4) -> Self
Creates a matrix from column vectors.
Sourcepub const fn from_cols_array(values: [f32; 16]) -> Self
pub const fn from_cols_array(values: [f32; 16]) -> Self
Creates a matrix from a column-major array.
Sourcepub fn perspective(fov_y_rad: f32, aspect: f32, near: f32, far: f32) -> Self
pub fn perspective(fov_y_rad: f32, aspect: f32, near: f32, far: f32) -> Self
Returns a right-handed perspective projection matrix with WebGPU depth.
Sourcepub fn orthographic(
left: f32,
right: f32,
bottom: f32,
top: f32,
near: f32,
far: f32,
) -> Self
pub fn orthographic( left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32, ) -> Self
Returns a right-handed orthographic projection matrix with WebGPU depth.
Sourcepub fn look_at(eye: Vec3, target: Vec3, up: Vec3) -> Self
pub fn look_at(eye: Vec3, target: Vec3, up: Vec3) -> Self
Returns a right-handed view matrix looking from eye to target.
Sourcepub fn from_translation(value: Vec3) -> Self
pub fn from_translation(value: Vec3) -> Self
Creates a translation matrix.
Sourcepub fn from_rotation(rotation: Quat) -> Self
pub fn from_rotation(rotation: Quat) -> Self
Creates a rotation matrix from a quaternion.
Sourcepub fn from_scale(value: Vec3) -> Self
pub fn from_scale(value: Vec3) -> Self
Creates a scale matrix.
Sourcepub fn from_trs(translation: Vec3, rotation: Quat, scale: Vec3) -> Self
pub fn from_trs(translation: Vec3, rotation: Quat, scale: Vec3) -> Self
Creates a matrix from translation, rotation, and scale.
Sourcepub fn mul_vec3(self, rhs: Vec3) -> Vec3
pub fn mul_vec3(self, rhs: Vec3) -> Vec3
Transforms a point and applies homogeneous divide when possible.
Sourcepub fn decompose(self) -> Option<Transform>
pub fn decompose(self) -> Option<Transform>
Decomposes a TRS matrix into translation, rotation, and scale.
Sourcepub fn to_cols_array(self) -> [f32; 16]
pub fn to_cols_array(self) -> [f32; 16]
Returns the matrix as a column-major array.
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 UnsafeUnpin 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