Struct slender_math::Matrix4x4
source · #[repr(C, align(16))]pub struct Matrix4x4(_);Expand description
Column-major 4x4 matrix, indexed as [row, column]
Implementations§
source§impl Matrix4x4
impl Matrix4x4
sourcepub const fn new(
e00: f32,
e10: f32,
e20: f32,
e30: f32,
e01: f32,
e11: f32,
e21: f32,
e31: f32,
e02: f32,
e12: f32,
e22: f32,
e32: f32,
e03: f32,
e13: f32,
e23: f32,
e33: f32
) -> Self
pub const fn new( e00: f32, e10: f32, e20: f32, e30: f32, e01: f32, e11: f32, e21: f32, e31: f32, e02: f32, e12: f32, e22: f32, e32: f32, e03: f32, e13: f32, e23: f32, e33: f32 ) -> Self
Creates a new matrix from individual elements
sourcepub const fn from_array(array: [[f32; 4]; 4]) -> Self
pub const fn from_array(array: [[f32; 4]; 4]) -> Self
Creates a new matrix from the given array
sourcepub fn is_identity(&self, epsilon: f32) -> bool
pub fn is_identity(&self, epsilon: f32) -> bool
Checks whether this matrix is the identity matrix, up to a certain error
sourcepub fn translation_x(translation: f32) -> Self
pub fn translation_x(translation: f32) -> Self
Creates a matrix representing a translation along the X axis
sourcepub fn translation_y(translation: f32) -> Self
pub fn translation_y(translation: f32) -> Self
Creates a matrix representing a translation along the Y axis
sourcepub fn translation_z(translation: f32) -> Self
pub fn translation_z(translation: f32) -> Self
Creates a matrix representing a translation along the Z axis
sourcepub fn translation(translation: Vector3f) -> Self
pub fn translation(translation: Vector3f) -> Self
Creates a matrix representing a translation
sourcepub fn rotation_x(angle: f32) -> Self
pub fn rotation_x(angle: f32) -> Self
Creates a matrix representing a rotation around the X axis
sourcepub fn rotation_y(angle: f32) -> Self
pub fn rotation_y(angle: f32) -> Self
Creates a matrix representing a rotation around the Y axis
sourcepub fn rotation_z(angle: f32) -> Self
pub fn rotation_z(angle: f32) -> Self
Creates a matrix representing a rotation around the Z axis
sourcepub fn rotation(rotation: Quaternion) -> Self
pub fn rotation(rotation: Quaternion) -> Self
Creates a matrix representing a rotation
sourcepub fn from_yaw_pitch_roll(yaw: f32, pitch: f32, roll: f32) -> Self
pub fn from_yaw_pitch_roll(yaw: f32, pitch: f32, roll: f32) -> Self
Creates a matrix representing a rotation specified by yaw, pitch and roll angles
sourcepub fn from_scale_rotation_translation(
scale: Vector3f,
rotation: Quaternion,
translation: Vector3f
) -> Self
pub fn from_scale_rotation_translation( scale: Vector3f, rotation: Quaternion, translation: Vector3f ) -> Self
Creates a matrix representing a transformation specified by scale, rotation and translation, applied in that order
sourcepub fn transposed(&self) -> Self
pub fn transposed(&self) -> Self
Transposes this matrix
sourcepub fn determinant(&self) -> f32
pub fn determinant(&self) -> f32
Calculates the determinant of this matrix
sourcepub fn transform_inverse(&self) -> Self
pub fn transform_inverse(&self) -> Self
Calculates the inverse as long as the input matrix is a transform (only translation, rotation, scaling)
sourcepub fn lerp(lhs: &Self, rhs: &Self, t: f32) -> Self
pub fn lerp(lhs: &Self, rhs: &Self, t: f32) -> Self
Linearily interpolates between this matrix and rhs
sourcepub fn mul_no_translate(&self, rhs: Vector3f) -> Vector3f
pub fn mul_no_translate(&self, rhs: Vector3f) -> Vector3f
Multiples the matrix with a vector while not applying translation
sourcepub fn look_to(pos: Vector3f, dir: Vector3f, up: Vector3f) -> Self
pub fn look_to(pos: Vector3f, dir: Vector3f, up: Vector3f) -> Self
Creates a matrix representing the transformation of looking from a position in a direction
sourcepub fn look_at(pos: Vector3f, target: Vector3f, up: Vector3f) -> Self
pub fn look_at(pos: Vector3f, target: Vector3f, up: Vector3f) -> Self
Creates a matrix representing the transformation of looking from a position at a target
sourcepub fn perspective(
fov_y: f32,
aspect_ratio: f32,
near_plane: f32,
far_plane: f32
) -> Self
pub fn perspective( fov_y: f32, aspect_ratio: f32, near_plane: f32, far_plane: f32 ) -> Self
Creates a perspective projection matrix
Constraints:
- fov_y > 0.0
- aspect_ration > 0.0
- near_plane > 1.0
- far_plane > near_plane
sourcepub fn orthographic(left: f32, right: f32, bottom: f32, top: f32) -> Self
pub fn orthographic(left: f32, right: f32, bottom: f32, top: f32) -> Self
Creates an orthographic projection matrix
sourcepub fn orthographic_centered(width: f32, height: f32) -> Self
pub fn orthographic_centered(width: f32, height: f32) -> Self
Creates a centered orthographic projection matrix
Trait Implementations§
source§impl PartialEq<Matrix4x4> for Matrix4x4
impl PartialEq<Matrix4x4> for Matrix4x4
impl Copy for Matrix4x4
impl Pod for Matrix4x4
impl StructuralPartialEq for Matrix4x4
Auto Trait Implementations§
impl RefUnwindSafe for Matrix4x4
impl Send for Matrix4x4
impl Sync for Matrix4x4
impl Unpin for Matrix4x4
impl UnwindSafe for Matrix4x4
Blanket Implementations§
source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere T: AnyBitPattern,
§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.