[−][src]Struct duku::Mat4
4x4 Matrix.
Used for transforming vectors
Is column-major
Examples
let vector = Vec3::new(2.0, 0.0, 0.0); let matrix = Mat4::scale([5.0, 1.0, 1.0]); let scaled = matrix * vector;
Fields
x: Vec4
the X column
y: Vec4
the Y column
z: Vec4
the Z column
w: Vec4
the W column
Implementations
impl Mat4
[src]
pub fn columns(
x: impl Into<Vec4>,
y: impl Into<Vec4>,
z: impl Into<Vec4>,
w: impl Into<Vec4>
) -> Self
[src]
x: impl Into<Vec4>,
y: impl Into<Vec4>,
z: impl Into<Vec4>,
w: impl Into<Vec4>
) -> Self
Create matrix from column vectors
pub fn rows(
x: impl Into<Vec4>,
y: impl Into<Vec4>,
z: impl Into<Vec4>,
w: impl Into<Vec4>
) -> Self
[src]
x: impl Into<Vec4>,
y: impl Into<Vec4>,
z: impl Into<Vec4>,
w: impl Into<Vec4>
) -> Self
Create matrix from row vectors
pub fn identity() -> Self
[src]
Create identity matrix
pub fn translation(vector: impl Into<Vec3>) -> Self
[src]
Create translation matrix
Translation matrix moves vectors around
pub fn scale(vector: impl Into<Vec3>) -> Self
[src]
Create scale matrix
Scale matrix scales vectors
pub fn euler_rotation(x: f32, y: f32, z: f32) -> Self
[src]
Create rotation matrix with euler angles
This rotation's yaw, pitch and roll are z, y and x
pub fn axis_rotation(axis: impl Into<Vec3>, angle: f32) -> Self
[src]
Create rotation matrix around axis
This rotates vectors around axis by the angle
pub fn look_rotation(forward: impl Into<Vec3>, up: impl Into<Vec3>) -> Self
[src]
Create rotation matrix to rotate towards direction
up
is used as a guide to try aligning to
pub fn perspective(fov: f32, aspect: f32, near: f32, far: f32) -> Self
[src]
Create perspective projection matrix
This is a left-handed matrix with Z in range of [0; 1]
pub fn orthographic(width: f32, height: f32, near: f32, far: f32) -> Self
[src]
Create orthographic projection matrix
This is a left-handed matrix with Z in range of [0; 1]
pub fn compose(position: Vec3, scale: Vec3, rotation: Quat) -> Self
[src]
Create matrix from position, scale and rotation
Oposite of decompose.
pub fn inverse(&self) -> Option<Self>
[src]
Calculate the inverse of the matrix
pub fn decompose(self) -> (Vec3, Vec3, Quat)
[src]
Separate translation, scale and rotation parts of the matrix
pub const fn rx(&self) -> Vec4
[src]
Access the X row of the matrix
pub const fn ry(&self) -> Vec4
[src]
Access the Y row of the matrix
pub const fn rz(&self) -> Vec4
[src]
Access the Z row of the matrix
pub const fn rw(&self) -> Vec4
[src]
Access the W row of the matrix
Trait Implementations
impl Clone for Mat4
[src]
impl Copy for Mat4
[src]
impl Debug for Mat4
[src]
impl Default for Mat4
[src]
impl From<[f32; 16]> for Mat4
[src]
impl From<Mat4> for Quat
[src]
impl From<Quat> for Mat4
[src]
impl Index<usize> for Mat4
[src]
impl IndexMut<usize> for Mat4
[src]
impl Into<[f32; 16]> for Mat4
[src]
impl Mul<Mat4> for Mat4
[src]
type Output = Self
The resulting type after applying the *
operator.
pub fn mul(self, rhs: Self) -> Self::Output
[src]
impl Mul<Vec3> for Mat4
[src]
type Output = Vec3
The resulting type after applying the *
operator.
pub fn mul(self, rhs: Vec3) -> Self::Output
[src]
impl Mul<Vec4> for Mat4
[src]
type Output = Vec4
The resulting type after applying the *
operator.
pub fn mul(self, rhs: Vec4) -> Self::Output
[src]
impl Mul<f32> for Mat4
[src]
type Output = Mat4
The resulting type after applying the *
operator.
pub fn mul(self, rhs: f32) -> Self::Output
[src]
impl MulAssign<Mat4> for Mat4
[src]
pub fn mul_assign(&mut self, rhs: Self)
[src]
impl PartialEq<Mat4> for Mat4
[src]
impl StructuralPartialEq for Mat4
[src]
Auto Trait Implementations
impl RefUnwindSafe for Mat4
impl Send for Mat4
impl Sync for Mat4
impl Unpin for Mat4
impl UnwindSafe for Mat4
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,