Struct Matrix4

Source
#[repr(C)]
pub struct Matrix4(pub [Vector4; 4]);
Expand description

A 4x4 matrix, suitable for 3D transformations.

Tuple Fields§

§0: [Vector4; 4]

Implementations§

Source§

impl Matrix4

Source

pub const fn from_1d_array(a: [f32; 16]) -> Self

A new matrix from a 1D array.

Source

pub const fn from_2d_array(a: [[f32; 4]; 4]) -> Self

A new matrix from a 2D array.

Source

pub const fn identity() -> Self

The identity matrix.

Source

pub const fn zero() -> Self

A matrix composed entirely of zeroes.

Source

pub fn look_at(eye: Point, target: Point, up: Vector3) -> Self

A look-at matrix suitable for positioning a camera.

Source

pub fn perspective( aspect_ratio: f32, fov_radians: f32, znear: f32, zfar: f32, ) -> Self

A perspective matrix suitable for use as a camera projection.

Source

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

An orthographic matrix suitable for rendering user interfaces.

Source

pub fn translation(v: Vector3) -> Self

A matrix that translates by the given vector.

Source

pub fn rotation_x(angle_radians: f32) -> Self

A matrix that rotates around the x-axis.

Source

pub fn rotation_y(angle_radians: f32) -> Self

A matrix that rotates around the y-axis.

Source

pub fn rotation_z(angle_radians: f32) -> Self

A matrix that rotates around the z-axis.

Source

pub fn rotation_axis_angle(axis: Vector3, angle_radians: f32) -> Self

A matrix that rotates around an arbitrary axis.

Source

pub fn rotation_from_vector_to_vector(start: Vector3, end: Vector3) -> Self

A matrix that rotates from a given vector to another.

Source

pub fn uniform_scale(scale: f32) -> Self

A matrix that scales uniformly in all dimensions.

Source

pub fn row(&self, i: usize) -> Vector4

Obtain the specified row vector of this matrix.

Source

pub fn column(&self, i: usize) -> Vector4

Obtain the specified column vector of this matrix.

Source

pub fn transpose(&self) -> Self

The transpose of this matrix (i.e. this matrix flipped along the diagonal)

Source

pub fn invert(&self) -> Self

The inverse of this matrix.

Source

pub fn as_slice(&self) -> &[f32]

Trait Implementations§

Source§

impl Clone for Matrix4

Source§

fn clone(&self) -> Matrix4

Returns a duplicate 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 Matrix4

Source§

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

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

impl Mul<&Matrix4> for Matrix4

Source§

type Output = Matrix4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Matrix4) -> Self

Performs the * operation. Read more
Source§

impl Mul<Matrix4> for Point

Source§

type Output = Point

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Matrix4) -> Point

Performs the * operation. Read more
Source§

impl Mul<Matrix4> for Vector3

Source§

type Output = Vector3

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Matrix4) -> Vector3

Performs the * operation. Read more
Source§

impl Mul<Matrix4> for Vector4

Source§

type Output = Vector4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Matrix4) -> Vector4

Performs the * operation. Read more
Source§

impl Mul<Point> for Matrix4

Source§

type Output = Point

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Point) -> Point

Performs the * operation. Read more
Source§

impl Mul<Vector3> for Matrix4

Source§

type Output = Vector3

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vector3) -> Vector3

Performs the * operation. Read more
Source§

impl Mul<Vector4> for Matrix4

Source§

type Output = Vector4

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vector4) -> Vector4

Performs the * operation. Read more
Source§

impl Mul for Matrix4

Source§

type Output = Matrix4

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl NearlyEqual for &Matrix4

Source§

fn nearly_equals(self, rhs: Self) -> bool

Source§

impl PartialEq for Matrix4

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Copy for Matrix4

Source§

impl StructuralPartialEq for Matrix4

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.