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

source

pub const IDENTITY: Self = _

A matrix representing no transformation

source

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

source

pub const fn from_array(array: [[f32; 4]; 4]) -> Self

Creates a new matrix from the given array

source

pub const fn to_array(&self) -> [[f32; 4]; 4]

Converts the matrix into an array

source

pub fn is_identity(&self, epsilon: f32) -> bool

Checks whether this matrix is the identity matrix, up to a certain error

source

pub fn translation_x(translation: f32) -> Self

Creates a matrix representing a translation along the X axis

source

pub fn translation_y(translation: f32) -> Self

Creates a matrix representing a translation along the Y axis

source

pub fn translation_z(translation: f32) -> Self

Creates a matrix representing a translation along the Z axis

source

pub fn translation(translation: Vector3f) -> Self

Creates a matrix representing a translation

source

pub fn scaling_x(scale: f32) -> Self

Creates a matrix representing a scaling along the X axis

source

pub fn scaling_y(scale: f32) -> Self

Creates a matrix representing a scaling along the Y axis

source

pub fn scaling_z(scale: f32) -> Self

Creates a matrix representing a scaling along the Z axis

source

pub fn scaling(scale: Vector3f) -> Self

Creates a matrix representing a scaling

source

pub fn rotation_x(angle: f32) -> Self

Creates a matrix representing a rotation around the X axis

source

pub fn rotation_y(angle: f32) -> Self

Creates a matrix representing a rotation around the Y axis

source

pub fn rotation_z(angle: f32) -> Self

Creates a matrix representing a rotation around the Z axis

source

pub fn rotation(rotation: Quaternion) -> Self

Creates a matrix representing a rotation

source

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

source

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

source

pub fn transposed(&self) -> Self

Transposes this matrix

source

pub fn determinant(&self) -> f32

Calculates the determinant of this matrix

source

pub fn transform_inverse(&self) -> Self

Calculates the inverse as long as the input matrix is a transform (only translation, rotation, scaling)

source

pub fn inverse(&self) -> Self

Calculates the inverse of this matrix

source

pub fn lerp(lhs: &Self, rhs: &Self, t: f32) -> Self

Linearily interpolates between this matrix and rhs

source

pub fn mul_no_translate(&self, rhs: Vector3f) -> Vector3f

Multiples the matrix with a vector while not applying translation

source

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

source

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

source

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
source

pub fn orthographic(left: f32, right: f32, bottom: f32, top: f32) -> Self

Creates an orthographic projection matrix

source

pub fn orthographic_centered(width: f32, height: f32) -> Self

Creates a centered orthographic projection matrix

Trait Implementations§

source§

impl Clone for Matrix4x4

source§

fn clone(&self) -> Matrix4x4

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Matrix4x4

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Matrix4x4

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<Matrix2x3> for Matrix4x4

source§

fn from(other: Matrix2x3) -> Self

Converts to this type from the input type.
source§

impl Index<(usize, usize)> for Matrix4x4

§

type Output = f32

The returned type after indexing.
source§

fn index(&self, index: (usize, usize)) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl IndexMut<(usize, usize)> for Matrix4x4

source§

fn index_mut(&mut self, index: (usize, usize)) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl Mul<Matrix4x4> for Matrix4x4

§

type Output = Matrix4x4

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Vector3f> for Matrix4x4

§

type Output = Vector3f

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Vector3f) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Vector4f> for Matrix4x4

§

type Output = Vector4f

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Vector4f) -> Self::Output

Performs the * operation. Read more
source§

impl PartialEq<Matrix4x4> for Matrix4x4

source§

fn eq(&self, other: &Matrix4x4) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Zeroable for Matrix4x4

source§

fn zeroed() -> Self

source§

impl Copy for Matrix4x4

source§

impl Pod for Matrix4x4

source§

impl StructuralPartialEq for Matrix4x4

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CheckedBitPattern for Twhere T: AnyBitPattern,

§

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

If this function returns true, then it must be valid to reinterpret bits as &Self.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> AnyBitPattern for Twhere T: Pod,

source§

impl<T> NoUninit for Twhere T: Pod,