#[repr(C)]pub struct Matrix4x4 {
pub m: [f32; 16],
}Expand description
4x4 homogeneous transformation matrix stored in column-major order.
Matrix indices: [ 0 4 8 12 ] [ 1 5 9 13 ] [ 2 6 10 14 ] [ 3 7 11 15 ]
Fields§
§m: [f32; 16]Implementations§
Source§impl Matrix4x4
impl Matrix4x4
pub const IDENTITY: Matrix4x4
pub const fn identity() -> Matrix4x4
pub const fn from_array(m: [f32; 16]) -> Matrix4x4
Sourcepub const fn from_2d(
a: f32,
b: f32,
c: f32,
d: f32,
e: f32,
f: f32,
) -> Matrix4x4
pub const fn from_2d( a: f32, b: f32, c: f32, d: f32, e: f32, f: f32, ) -> Matrix4x4
Constructs a 4x4 matrix from 2D affine matrix components:
matrix(a, b, c, d, e, f) where a, c, e are row 0, b, d, f are row 1.
Sourcepub fn rotation_z(rad: f32) -> Matrix4x4
pub fn rotation_z(rad: f32) -> Matrix4x4
Creates a rotation matrix around the Z axis (standard 2D rotation).
Sourcepub fn rotation_x(rad: f32) -> Matrix4x4
pub fn rotation_x(rad: f32) -> Matrix4x4
Creates a rotation matrix around the X axis.
Sourcepub fn rotation_y(rad: f32) -> Matrix4x4
pub fn rotation_y(rad: f32) -> Matrix4x4
Creates a rotation matrix around the Y axis.
Sourcepub fn rotation_axis(x: f32, y: f32, z: f32, rad: f32) -> Matrix4x4
pub fn rotation_axis(x: f32, y: f32, z: f32, rad: f32) -> Matrix4x4
Creates a rotation matrix around an arbitrary 3D axis [x, y, z].
Sourcepub fn skew(ax_rad: f32, ay_rad: f32) -> Matrix4x4
pub fn skew(ax_rad: f32, ay_rad: f32) -> Matrix4x4
Creates a 2D skew matrix given horizontal and vertical angles in radians.
Sourcepub fn perspective(d: f32) -> Matrix4x4
pub fn perspective(d: f32) -> Matrix4x4
Creates a perspective projection matrix where d is the distance to the projection plane.
Sourcepub fn multiply(&self, rhs: &Matrix4x4) -> Matrix4x4
pub fn multiply(&self, rhs: &Matrix4x4) -> Matrix4x4
Multiplies self by rhs: Result = self * rhs.
Sourcepub fn determinant(&self) -> f32
pub fn determinant(&self) -> f32
Computes the determinant of the 4x4 matrix using Laplace expansion.
Sourcepub fn transform_point2d(&self, p: Point) -> Point
pub fn transform_point2d(&self, p: Point) -> Point
Transforms a 2D point using homogeneous coordinates with perspective divide.
Sourcepub fn transform_point(&self, x: f32, y: f32) -> (f32, f32)
pub fn transform_point(&self, x: f32, y: f32) -> (f32, f32)
Transforms 2D coordinates (x, y) using homogeneous coordinates with perspective divide.
Sourcepub fn transform_rect(&self, r: Rect) -> Rect
pub fn transform_rect(&self, r: Rect) -> Rect
Transforms an axis-aligned rectangle, computing its new bounding box.
Sourcepub fn transform_bounds(
&self,
x: f32,
y: f32,
width: f32,
height: f32,
) -> (f32, f32, f32, f32)
pub fn transform_bounds( &self, x: f32, y: f32, width: f32, height: f32, ) -> (f32, f32, f32, f32)
Transforms an axis-aligned rectangle (x, y, width, height) returning the new bounding box (min_x, min_y, w, h).
Sourcepub fn is_identity(&self) -> bool
pub fn is_identity(&self) -> bool
Returns true if this matrix is approximately the identity matrix.