Skip to main content

Matrix4x4

Struct Matrix4x4 

Source
pub struct Matrix4x4 { /* private fields */ }
Expand description

A 4x4 matrix stored in column-major order, used for 3D transformations.

Implementations§

Source§

impl Matrix4x4

Implements matrix operations for Matrix4x4.

Source

pub fn identity() -> Matrix4x4

Returns the identity matrix.

§Returns
  • Matrix4x4 - The identity matrix.
Source

pub fn translation(translation: Vector3D) -> Matrix4x4

Creates a translation matrix.

§Arguments
  • Vector3D - The translation vector.
§Returns
  • Matrix4x4 - The translation matrix.
Source

pub fn scaling(scale: Vector3D) -> Matrix4x4

Creates a scaling matrix.

§Arguments
  • Vector3D - The scale factors.
§Returns
  • Matrix4x4 - The scaling matrix.
Source

pub fn rotation(quaternion: Quaternion) -> Matrix4x4

Creates a rotation matrix from a quaternion.

§Arguments
  • Quaternion - The rotation quaternion.
§Returns
  • Matrix4x4 - The rotation matrix.
Source

pub fn perspective(fov: f64, aspect: f64, near: f64, far: f64) -> Matrix4x4

Creates a perspective projection matrix.

§Arguments
  • f64 - The vertical field of view in radians.
  • f64 - The aspect ratio (width / height).
  • f64 - The near clipping plane distance.
  • f64 - The far clipping plane distance.
§Returns
  • Matrix4x4 - The perspective projection matrix.
Source

pub fn orthographic( left: f64, right: f64, bottom: f64, top: f64, near: f64, far: f64, ) -> Matrix4x4

Creates an orthographic projection matrix.

§Arguments
  • f64 - The left boundary.
  • f64 - The right boundary.
  • f64 - The bottom boundary.
  • f64 - The top boundary.
  • f64 - The near clipping plane distance.
  • f64 - The far clipping plane distance.
§Returns
  • Matrix4x4 - The orthographic projection matrix.
Source

pub fn look_at(eye: Vector3D, target: Vector3D, up: Vector3D) -> Matrix4x4

Creates a view matrix using the “look at” convention.

§Arguments
  • Vector3D - The eye position.
  • Vector3D - The target position to look at.
  • Vector3D - The up direction.
§Returns
  • Matrix4x4 - The view matrix.
Source

pub fn multiply(&self, other: Matrix4x4) -> Matrix4x4

Multiplies this matrix by another.

§Arguments
  • Matrix4x4 - The other matrix.
§Returns
  • Matrix4x4 - The product matrix.
Source

pub fn transform_point(&self, point: Vector3D) -> Vector3D

Transforms a 3D point by this matrix, applying the perspective divide.

§Arguments
  • Vector3D - The point to transform.
§Returns
  • Vector3D - The transformed point.
Source§

impl Matrix4x4

Source

pub fn get_elements(&self) -> [f64; 16]

Source

pub fn get_mut_elements(&mut self) -> &mut [f64; 16]

Source

pub fn set_elements(&mut self, val: [f64; 16]) -> &mut Self

Source§

impl Matrix4x4

Source

pub fn new(elements: [f64; 16]) -> Self

Trait Implementations§

Source§

impl Clone for Matrix4x4

Source§

fn clone(&self) -> Matrix4x4

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Matrix4x4

Source§

impl Debug for Matrix4x4

Source§

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

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

impl Default for Matrix4x4

Implements Default for Matrix4x4 as the identity matrix.

Source§

fn default() -> Matrix4x4

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Matrix4x4

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Matrix4x4

Source§

fn partial_cmp(&self, other: &Matrix4x4) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Matrix4x4

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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 T
where T: Clone,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more