[−][src]Struct duku::Matrix4
4x4 Matrix.
Used for transforming vectors
Note: column-major
Example
let vector = Vector3::new(2.0, 0.0, 0.0); let matrix = Matrix4::scale([5.0, 1.0, 1.0]); assert_eq!(matrix * vector, Vector3::new(10.0, 0.0, 0.0));
Fields
x: Vector4
the X column
y: Vector4
the Y column
z: Vector4
the Z column
w: Vector4
the W column
Implementations
impl Matrix4
[src]
pub fn columns(
x: impl Into<Vector4>,
y: impl Into<Vector4>,
z: impl Into<Vector4>,
w: impl Into<Vector4>
) -> Self
[src]
x: impl Into<Vector4>,
y: impl Into<Vector4>,
z: impl Into<Vector4>,
w: impl Into<Vector4>
) -> Self
Create matrix from column vectors
pub fn rows(
x: impl Into<Vector4>,
y: impl Into<Vector4>,
z: impl Into<Vector4>,
w: impl Into<Vector4>
) -> Self
[src]
x: impl Into<Vector4>,
y: impl Into<Vector4>,
z: impl Into<Vector4>,
w: impl Into<Vector4>
) -> Self
Create matrix from row vectors
pub fn identity() -> Self
[src]
Create identity matrix
pub fn translation(vector: impl Into<Vector3>) -> Self
[src]
Create translation matrix
Translation matrix moves vectors around
Example
let vector = Vector3::new(2.0, 0.0, 0.0); let matrix = Matrix4::translation([5.0, 1.0, 1.0]); assert_eq!(matrix * vector, Vector3::new(7.0, 1.0, 1.0));
pub fn scale(vector: impl Into<Vector3>) -> Self
[src]
Create scale matrix
Scale matrix scales vectors
Example
let vector = Vector3::new(2.0, 0.0, 0.0); let matrix = Matrix4::scale([5.0, 1.0, 1.0]); assert_eq!(matrix * vector, Vector3::new(10.0, 0.0, 0.0));
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<Vector3>, angle: f32) -> Self
[src]
Create rotation matrix around axis
This rotates vectors around axis by the angle
pub fn look_rotation(
forward: impl Into<Vector3>,
up: impl Into<Vector3>
) -> Self
[src]
forward: impl Into<Vector3>,
up: impl Into<Vector3>
) -> Self
Create rotation matrix to rotate towards direction
Note: 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
Note: 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
Note: this is a left-handed matrix with Z in range of [0; 1]
pub fn inverse(&self) -> Option<Self>
[src]
Calculate the inverse of the matrix
pub const fn rx(&self) -> Vector4
[src]
Access the X row of the matrix
pub const fn ry(&self) -> Vector4
[src]
Access the Y row of the matrix
pub const fn rz(&self) -> Vector4
[src]
Access the Z row of the matrix
pub const fn rw(&self) -> Vector4
[src]
Access the W row of the matrix
Trait Implementations
impl Clone for Matrix4
[src]
impl Copy for Matrix4
[src]
impl Debug for Matrix4
[src]
impl From<[f32; 16]> for Matrix4
[src]
impl From<Matrix4> for Quaternion
[src]
impl From<Matrix4> for Transform
[src]
impl From<Quaternion> for Matrix4
[src]
pub fn from(q: Quaternion) -> Self
[src]
impl From<Transform> for Matrix4
[src]
impl Index<usize> for Matrix4
[src]
type Output = Vector4
The returned type after indexing.
pub fn index(&self, index: usize) -> &Vector4
[src]
impl IndexMut<usize> for Matrix4
[src]
impl Into<[f32; 16]> for Matrix4
[src]
impl Mul<Matrix4> for Matrix4
[src]
type Output = Self
The resulting type after applying the *
operator.
pub fn mul(self, rhs: Self) -> Self::Output
[src]
impl Mul<Vector3> for Matrix4
[src]
type Output = Vector3
The resulting type after applying the *
operator.
pub fn mul(self, rhs: Vector3) -> Self::Output
[src]
impl Mul<Vector4> for Matrix4
[src]
type Output = Vector4
The resulting type after applying the *
operator.
pub fn mul(self, rhs: Vector4) -> Self::Output
[src]
impl Mul<f32> for Matrix4
[src]
type Output = Matrix4
The resulting type after applying the *
operator.
pub fn mul(self, rhs: f32) -> Self::Output
[src]
impl MulAssign<Matrix4> for Matrix4
[src]
pub fn mul_assign(&mut self, rhs: Self)
[src]
impl PartialEq<Matrix4> for Matrix4
[src]
impl StructuralPartialEq for Matrix4
[src]
Auto Trait Implementations
impl RefUnwindSafe for Matrix4
impl Send for Matrix4
impl Sync for Matrix4
impl Unpin for Matrix4
impl UnwindSafe for Matrix4
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>,