pub struct Mat4 { /* private fields */ }Expand description
Column-major 4x4 transformation and perspective projection matrix.
Implementations§
Source§impl Mat4
Matrix constructors, projection, and point projection for Mat4.
impl Mat4
Matrix constructors, projection, and point projection for Mat4.
Sourcepub fn from_trs_euler(
position: Vec3,
yaw_rad: f32,
pitch_rad: f32,
roll_rad: f32,
scale: Vec3,
) -> Self
pub fn from_trs_euler( position: Vec3, yaw_rad: f32, pitch_rad: f32, roll_rad: f32, scale: Vec3, ) -> Self
Builds a full 3D Euler TRS model matrix (translate * rotate_y(yaw) * rotate_x(pitch) * rotate_z(roll) * scale).
§Arguments
Vec3- World translation.f32- Y-axis yaw rotation in radians.f32- X-axis pitch rotation in radians.f32- Z-axis roll rotation in radians.Vec3- Non-uniform scale.
§Returns
Self- Composed 3D model transform matrix.
Sourcepub fn mul_point4(&self, vec_value: Vec3) -> [f32; 4]
pub fn mul_point4(&self, vec_value: Vec3) -> [f32; 4]
Sourcepub fn mul_point3(&self, vec_value: Vec3) -> Vec3
pub fn mul_point3(&self, vec_value: Vec3) -> Vec3
Sourcepub fn transform_bounds(&self, local: AxisAlignedBox3D) -> AxisAlignedBox3D
pub fn transform_bounds(&self, local: AxisAlignedBox3D) -> AxisAlignedBox3D
Transforms a local AxisAlignedBox3D into an enclosing world-space AxisAlignedBox3D via Arvo’s 18-multiply method (zero corner loop, zero trigonometry).
§Arguments
&Self- Affine model transformation matrix.AxisAlignedBox3D- Local-space bounding box.
§Returns
AxisAlignedBox3D- Tight world-space enclosing axis-aligned bounding box.
Sourcepub fn inverse_trs_euler(
position: Vec3,
yaw_rad: f32,
pitch_rad: f32,
roll_rad: f32,
scale: Vec3,
) -> Self
pub fn inverse_trs_euler( position: Vec3, yaw_rad: f32, pitch_rad: f32, roll_rad: f32, scale: Vec3, ) -> Self
Computes the exact analytical inverse of a TRS Euler matrix (S^-1 * R^T * T^-1) for object-space raytracing.
§Arguments
Vec3- World translation.f32- Y-axis yaw rotation in radians.f32- X-axis pitch rotation in radians.f32- Z-axis roll rotation in radians.Vec3- Non-uniform scale.
§Returns
Self- Exact inverse model matrix mapping world space back to local object space.
Sourcepub fn normal_basis_from_euler_scale(
yaw_rad: f32,
pitch_rad: f32,
roll_rad: f32,
scale: Vec3,
) -> [Vec3; 3]
pub fn normal_basis_from_euler_scale( yaw_rad: f32, pitch_rad: f32, roll_rad: f32, scale: Vec3, ) -> [Vec3; 3]
Computes the inverse-transpose 3x3 normal transformation basis [col_x, col_y, col_z] (R * S^-1) once per object.
§Arguments
f32- Y-axis yaw rotation in radians.f32- X-axis pitch rotation in radians.f32- Z-axis roll rotation in radians.Vec3- Non-uniform scale.
§Returns
[Vec3; 3]- Three column vectors transforming local normals into world space.
Source§impl Mat4
Extended quaternion TRS, orthographic projection, full 4x4 inversion, decomposition, and Blender basis conversions for Mat4.
impl Mat4
Extended quaternion TRS, orthographic projection, full 4x4 inversion, decomposition, and Blender basis conversions for Mat4.
Sourcepub const fn from_cols_array(elements: [f32; 16]) -> Self
pub const fn from_cols_array(elements: [f32; 16]) -> Self
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
Builds a right-handed orthographic projection matrix matching OpenGL/glTF clip depth [-1, 1].
§Arguments
f32- Left frustum bound.f32- Right frustum bound.f32- Bottom frustum bound.f32- Top frustum bound.f32- Near clipping plane distance.f32- Far clipping plane distance.
§Returns
Self- Orthographic projection matrix.
Sourcepub fn orthographic_mag(xmag: f32, ymag: f32, near: f32, far: f32) -> Self
pub fn orthographic_mag(xmag: f32, ymag: f32, near: f32, far: f32) -> Self
Builds a symmetric glTF 2.0 orthographic projection matrix from half-extents (xmag, ymag) and (near, far).
§Arguments
f32- Horizontal magnification half-width.f32- Vertical magnification half-height.f32- Near clipping distance.f32- Far clipping distance.
§Returns
Self- Symmetric orthographic projection matrix.
Sourcepub fn from_trs_quat(translation: Vec3, rotation: Quat, scale: Vec3) -> Self
pub fn from_trs_quat(translation: Vec3, rotation: Quat, scale: Vec3) -> Self
Sourcepub fn decompose_trs(&self) -> (Vec3, Quat, Vec3)
pub fn decompose_trs(&self) -> (Vec3, Quat, Vec3)
Sourcepub fn normal_matrix_3x3(&self) -> [Vec3; 3]
pub fn normal_matrix_3x3(&self) -> [Vec3; 3]
Sourcepub const fn blender_z_up_to_y_up() -> Self
pub const fn blender_z_up_to_y_up() -> Self
Returns the orthogonal change-of-basis matrix mapping Blender Z-up coordinates to Engine/glTF Y-up coordinates.
§Returns
Self- Basis conversion matrix(x, y, z) -> (x, z, -y).
Sourcepub const fn y_up_to_blender_z_up() -> Self
pub const fn y_up_to_blender_z_up() -> Self
Returns the inverse basis matrix mapping Engine/glTF Y-up coordinates back to Blender Z-up coordinates.
§Returns
Self- Basis conversion matrix(x, y, z) -> (x, -z, y).