Struct Mat4

Source
pub struct Mat4<T = f32>(pub [[T; 4]; 4]);
Expand description

A 4x4 matrix.

Tuple Fields§

§0: [[T; 4]; 4]

Implementations§

Source§

impl<T> Mat4<T>
where T: Float,

Source

pub fn new() -> Mat4<T>

Creates a zero matrix.

Source

pub fn identity() -> Mat4<T>

Creates an identity matrix.

Source

pub fn viewport(width: T, height: T) -> Mat4<T>

Creates viewport matrix mapping viewport top left to (0.0, 0.0) and bottom right to (width, height)

Source

pub fn look_at<E, C, U>(eye: E, target: C, up: U) -> Mat4<T>
where E: Vector<T>, C: Vector<T>, U: Vector<T>,

Creates a look-at matrix with the given eye position, target position, and up-vector.

Source

pub fn ortho<R>(rectangle: R, near: T, far: T) -> Mat4<T>
where ((T, T), (T, T)): From<R>,

Creates an orthogonal projection matrix with the given rectangular bounds at the near and far clipping plane.

Source

pub fn frustum<R>(rectangle: R, near: T, far: T) -> Mat4<T>
where ((T, T), (T, T)): From<R>,

Creates a frustum projection matrix with the given rectangular bounds at the near clipping plane and rectangle * (far / near) at the far clipping plane.

Source

pub fn perspective(fov_y: T, aspect: T, near: T, far: T) -> Mat4<T>

Creates a perspective projection matrix with the given field of view, aspect and near/far clipping planes.

Trait Implementations§

Source§

impl<T: Clone> Clone for Mat4<T>

Source§

fn clone(&self) -> Mat4<T>

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<T> Debug for Mat4<T>
where T: Debug,

Source§

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

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

impl<T> Default for Mat4<T>
where T: Float,

Source§

fn default() -> Self

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

impl<T> From<[[T; 4]; 4]> for Mat4<T>
where T: Copy,

Source§

fn from(source: [[T; 4]; 4]) -> Self

Converts to this type from the input type.
Source§

impl<T> Matrix<T> for Mat4<T>
where T: Float,

4x4 Matrices.

Source§

fn set<M>(&mut self, other: M) -> &mut Self
where [[T; 4]; 4]: From<M>,

Sets the matrix value from another matrix.
Source§

fn translate<V>(&mut self, translation_vector: V) -> &mut Self
where V: Vector<T>,

Translate matrix by given vector.
Source§

fn scale<V>(&mut self, scaling_vector: V) -> &mut Self
where V: Vector<T>,

Scale matrix by given vector.
Source§

fn scale_at<P, V>(&mut self, position: P, scaling_vector: V) -> &mut Self
where P: Vector<T>, V: Vector<T>,

Scales at given position.
Source§

fn rotate(&mut self, radians: T) -> &mut Self

Rotates the origin around z.
Source§

fn rotate_at<P>(&mut self, position: P, radians: T) -> &mut Self
where P: Vector<T>,

Rotates around z at given position.
Source§

fn rotate_axis<V>(&mut self, radians: T, axis: V) -> &mut Self
where Vec3<T>: From<V>,

Rotates around axis.
Source§

fn rotate_axis_at<P, V>( &mut self, position: P, radians: T, axis: V, ) -> &mut Self
where P: Vector<T>, Vec3<T>: From<V>,

Rotates around axis at given position.
Source§

fn get_rotation(&self) -> Self

Returns a pure rotation matrix for given matrix
Source§

fn get_translation(&self) -> Vec3<T>

Returns the matrix’s translation vector.
Source§

fn get_scale(&self) -> Vec3<T>

Returns the matrix’s scaling vector.
Source§

fn get_euler(&self) -> Vec3<T>

Get rotation matrix euler angles.
Source§

impl<T> Mul<T> for Mat4<T>
where T: Float,

Source§

type Output = Mat4<T>

The resulting type after applying the * operator.
Source§

fn mul(self, other: T) -> Mat4<T>

Performs the * operation. Read more
Source§

impl<T> Mul<Vec2<T>> for Mat4<T>
where T: Float,

Source§

fn mul(self, other: Vec2<T>) -> Vec2<T>

Multiplies the matrix with given vector operand, using 0 as z-component and 1 as w-component of the vector.

Source§

type Output = Vec2<T>

The resulting type after applying the * operator.
Source§

impl<T> Mul<Vec3<T>> for Mat4<T>
where T: Float,

Source§

fn mul(self, other: Vec3<T>) -> Vec3<T>

Multiplies the matrix with given vector operand using 1 as w-component of the vector.

Source§

type Output = Vec3<T>

The resulting type after applying the * operator.
Source§

impl<T> Mul for Mat4<T>
where T: Float,

Source§

type Output = Mat4<T>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Mat4<T>) -> Mat4<T>

Performs the * operation. Read more
Source§

impl<T: Copy> Copy for Mat4<T>

Auto Trait Implementations§

§

impl<T> Freeze for Mat4<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Mat4<T>
where T: RefUnwindSafe,

§

impl<T> Send for Mat4<T>
where T: Send,

§

impl<T> Sync for Mat4<T>
where T: Sync,

§

impl<T> Unpin for Mat4<T>
where T: Unpin,

§

impl<T> UnwindSafe for Mat4<T>
where T: UnwindSafe,

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<T> Vector<T> for T
where T: Copy,

Source§

fn as_vec3(&self, _: T) -> Vec3<T>

Returns the given value as a Vec3