Mat4

Struct Mat4 

Source
#[repr(C)]
pub struct Mat4(pub [f32; 16]);
Expand description

A 4x4 matrix

Tuple Fields§

§0: [f32; 16]

Implementations§

Source§

impl Mat4

Source

pub fn new() -> Self

Build a new (identity) Mat4, which applies no transformations.

Source

pub fn ptr(&self) -> *const f32

Returns a pointer to the matrix, readable by OpenGL.

Source

pub fn add(&mut self, mat: Mat4)

Adds mat to self

Source

pub fn mult(&mut self, mat: Mat4)

Multiplies this Mat4 (self) with another one (mat), further from the initial vertex position vector, so the resulting transformation will be the chaining of both matrices’ transformations: first self, then mat.

Source

pub fn div(&mut self, scalar: f32)

Divides self by a float, scalar.

Source

pub fn interpolate(&mut self, mat: Mat4, advancement: f32)

Interpolates self with mat given the advancement (0.0 to 1.0)

Source

pub fn scale(x_scale: f32, y_scale: f32, z_scale: f32) -> Self

Add a scale transformation to the Mat4, for each axis. The scale center is (0.0, 0.0, 0.0).

Source

pub fn rotate_x(angle: f32) -> Self

Add a rotation transformation to the Mat4 around the X axis, clockiwse. The rotation center is (0.0, 0.0, 0.0).

Source

pub fn rotate_y(angle: f32) -> Self

Add a rotation transformation to the Mat4 around the Y axis, clockiwse. The rotation center is (0.0, 0.0, 0.0).

Source

pub fn rotate_z(angle: f32) -> Self

Add a rotation transformation to the Mat4 around the Z axis, clockiwse. The rotation center is (0.0, 0.0, 0.0).

Source

pub fn translate(x_move: f32, y_move: f32, z_move: f32) -> Self

Add a translation transformation to the Mat4.

Source

pub fn lookat( eye_x: f32, eye_y: f32, eye_z: f32, target_x: f32, target_y: f32, target_z: f32, up_x: f32, up_y: f32, up_z: f32, ) -> Self

For view matrix. Moves the “camera” to (eye_x, eye_y, eye_z), looking at (target_x, target_y, target_z), with athe (up_x, up_y, up_z) up vector.

Source

pub fn project_orthographic( l: f32, r: f32, b: f32, t: f32, n: f32, f: f32, ) -> Self

For projection matrix. Defines an orthographic projection matrix with the given [left-right] - [top-bottom] - [near-far] frustrum. The default Frustrum is set to left-right: [-1.0, 1.0], top-bottom: [-1.0, 1.0], near-far: [-1.0, 1.0]

Source

pub fn project_perspective( l: f32, r: f32, b: f32, t: f32, n: f32, f: f32, ) -> Self

For projection matrix. Defines an perspective projection matrix with the given [left-right] - [top-bottom] - [near-far] frustrum. The default Frustrum is set to left-right: [-1.0, 1.0], top-bottom: [-1.0, 1.0], near-far: [-1.0, 1.0]

Trait Implementations§

Source§

impl Clone for Mat4

Source§

fn clone(&self) -> Mat4

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 Mat4

Source§

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

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

impl Copy for Mat4

Auto Trait Implementations§

§

impl Freeze for Mat4

§

impl RefUnwindSafe for Mat4

§

impl Send for Mat4

§

impl Sync for Mat4

§

impl Unpin for Mat4

§

impl UnwindSafe for Mat4

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.