Struct ultraviolet::mat::Mat4x4[][src]

#[repr(C)]pub struct Mat4x4 {
    pub cols: [Vec4x4; 4],
}

A 4x4 square matrix.

Useful for performing linear transformations (rotation, scaling) on 4d vectors, or for performing arbitrary transformations (linear + translation, projection, etc) on homogeneous 3d vectors.

Note that most constructors assume that the matrix will be used as a homogeneous 3d transformation matrix.

Fields

cols: [Vec4x4; 4]

Implementations

impl Mat4x4[src]

pub const fn new(col1: Vec4x4, col2: Vec4x4, col3: Vec4x4, col4: Vec4x4) -> Self[src]

pub fn identity() -> Self[src]

pub fn from_translation(trans: Vec3x4) -> Self[src]

Assumes homogeneous 3d coordinates.

pub fn from_scale(scale: f32x4) -> Self[src]

Assumes homogeneous 3d coordinates.

pub fn from_nonuniform_scale(scale: Vec3x4) -> Self[src]

Assumes homogeneous 3d coordinates.

pub fn from_scale_4d(scale: f32x4) -> Self[src]

Full 4d diagonal matrix.

pub fn from_nonuniform_scale_4d(scale: Vec4x4) -> Self[src]

Full 4d nonuniform scaling matrix.

pub fn from_euler_angles(roll: f32x4, pitch: f32x4, yaw: f32x4) -> Self[src]

Angles are applied in the order roll -> pitch -> yaw

  • Roll is rotation inside the xy plane (“around the z axis”)
  • Pitch is rotation inside the yz plane (“around the x axis”)
  • Yaw is rotation inside the xz plane (“around the y axis”)

Assumes homogeneous 3d coordinates.

Important: This function assumes a right-handed, y-up coordinate space where:

  • +X axis points right
  • +Y axis points up
  • +Z axis points towards the viewer (i.e. out of the screen)

This means that you may see unexpected behavior when used with OpenGL or DirectX as they use a different coordinate system. You should use the appropriate projection matrix in projection module to fit your use case to remedy this.

pub fn from_rotation_x(angle: f32x4) -> Self[src]

Create a new rotation matrix from a rotation “about the x axis”. This is here as a convenience function for users coming from other libraries; it is more proper to think of this as a rotation in the yz plane.

Assumes homogeneous 3d coordinates.

Important: This function assumes a right-handed, y-up coordinate space where:

  • +X axis points right
  • +Y axis points up
  • +Z axis points towards the viewer (i.e. out of the screen)

This means that you may see unexpected behavior when used with OpenGL or DirectX as they use a different coordinate system. You should use the appropriate projection matrix in projection module to fit your use case to remedy this.

pub fn from_rotation_y(angle: f32x4) -> Self[src]

Create a new rotation matrix from a rotation “about the y axis”. This is here as a convenience function for users coming from other libraries; it is more proper to think of this as a rotation in the xz plane.

Assumes homogeneous 3d coordinates.

Important: This function assumes a right-handed, y-up coordinate space where:

  • +X axis points right
  • +Y axis points up
  • +Z axis points towards the viewer (i.e. out of the screen)

This means that you may see unexpected behavior when used with OpenGL or DirectX as they use a different coordinate system. You should use the appropriate projection matrix in projection module to fit your use case to remedy this.

pub fn from_rotation_z(angle: f32x4) -> Self[src]

Create a new rotation matrix from a rotation “about the z axis”. This is here as a convenience function for users coming from other libraries; it is more proper to think of this as a rotation in the xy plane.

Assumes homogeneous 3d coordinates.

Important: This function assumes a right-handed, y-up coordinate space where:

  • +X axis points right
  • +Y axis points up
  • +Z axis points towards the viewer (i.e. out of the screen)

This means that you may see unexpected behavior when used with OpenGL or DirectX as they use a different coordinate system. You should use the appropriate projection matrix in projection module to fit your use case to remedy this.

pub fn from_angle_plane(angle: f32x4, plane: Bivec3x4) -> Self[src]

Construct a rotation matrix given a bivector which defines a plane and rotation orientation, and a rotation angle.

plane must be normalized!

This is the equivalent of an axis-angle rotation.

Assumes homogeneous 3d coordinates.

pub fn translate(&mut self, translation: &Vec3x4)[src]

Assumes homogeneous 3d coordinates.

pub fn translated(&self, translation: &Vec3x4) -> Self[src]

Assumes homogeneous 3d coordinates.

pub fn look_at(eye: Vec3x4, at: Vec3x4, up: Vec3x4) -> Self[src]

Constructs a ‘look-at’ matrix from an eye position, a focus position to look towards, and a vector that defines the ‘up’ direction.

This function assumes a right-handed, y-up coordinate space.

pub fn look_at_lh(eye: Vec3x4, at: Vec3x4, up: Vec3x4) -> Self[src]

Constructs a ‘look-at’ matrix from an eye position, a focus position to look towards, and a vector that defines the ‘up’ direction.

This function assumes a left-handed, y-up coordinate space.

pub fn transpose(&mut self)[src]

pub fn transposed(&self) -> Self[src]

pub fn inverse(&mut self)[src]

If this matrix is not currently invertable, this function will return an invalid inverse. This status is not checked by the library.

pub fn determinant(&self) -> f32x4[src]

pub fn adjugate(&self) -> Self[src]

The adjugate of this matrix, i.e. the transpose of the cofactor matrix.

This is equivalent to the inverse but without dividing by the determinant of the matrix, which can be useful in some contexts for better performance.

One such case is when this matrix is interpreted as a a homogeneous transformation matrix, in which case uniform scaling will not affect the resulting projected 3d version of transformed points or vectors.

pub fn inversed(&self) -> Self[src]

If this matrix is not currently invertable, this function will return an invalid inverse. This status is not checked by the library.

pub fn transform_vec3(&self, vec: Vec3x4) -> Vec3x4[src]

Transform a Vec3 by self, interpreting it as a vector.

pub fn transform_point3(&self, point: Vec3x4) -> Vec3x4[src]

Transform a Vec3 by self, interpreting it as a point.

pub fn extract_translation(&self) -> Vec3x4[src]

If self represents an affine transformation, return its translation components. Otherwise, the returned value has undefined properties.

pub fn extract_rotation(&self) -> Rotor3x4[src]

If the 3x3 left upper block of self is a rotation, return the corresponding rotor. Otherwise, the returned value is a Rotor3 with undefined properties.

pub fn into_isometry(&self) -> Isometry3x4[src]

If self represents an Isometry3 (i.e. self is a product of the from T * R where T is a translation and R a rotation), return the isometry

If self does not represent an isometry, the returned value has undefined properties.

pub fn truncate(&self) -> Mat3x4[src]

Truncate self to a matrix consisting of the 3x3 left upper block. If you need a rotation, consider using Self::extract_rotation() instead.

pub fn layout() -> Layout[src]

pub fn as_array(&self) -> &[f32x4; 16][src]

pub fn as_component_array(&self) -> &[Vec4x4; 4][src]

pub fn as_slice(&self) -> &[f32x4][src]

pub fn as_component_slice(&self) -> &[Vec4x4][src]

pub fn as_byte_slice(&self) -> &[u8][src]

pub fn as_mut_slice(&mut self) -> &mut [f32x4][src]

pub fn as_mut_component_slice(&mut self) -> &mut [Vec4x4][src]

pub fn as_mut_byte_slice(&mut self) -> &mut [u8][src]

pub const fn as_ptr(&self) -> *const f32x4[src]

Returns a constant unsafe pointer to the underlying data in the underlying type. This function is safe because all types here are repr(C) and can be represented as their underlying type.

Safety

It is up to the caller to correctly use this pointer and its bounds.

pub fn as_mut_ptr(&mut self) -> *mut f32x4[src]

Returns a mutable unsafe pointer to the underlying data in the underlying type. This function is safe because all types here are repr(C) and can be represented as their underlying type.

Safety

It is up to the caller to correctly use this pointer and its bounds.

Trait Implementations

impl Add<Mat4x4> for Mat4x4[src]

type Output = Self

The resulting type after applying the + operator.

impl AddAssign<Mat4x4> for Mat4x4[src]

impl Clone for Mat4x4[src]

impl Copy for Mat4x4[src]

impl Debug for Mat4x4[src]

impl Default for Mat4x4[src]

impl From<&'_ [f32x4; 16]> for Mat4x4[src]

impl From<[[f32x4; 4]; 4]> for Mat4x4[src]

impl From<[f32x4; 16]> for Mat4x4[src]

impl Index<usize> for Mat4x4[src]

type Output = Vec4x4

The returned type after indexing.

impl IndexMut<usize> for Mat4x4[src]

impl Mul<Mat4x4> for Mat4x4[src]

type Output = Self

The resulting type after applying the * operator.

impl Mul<Mat4x4> for f32x4[src]

type Output = Mat4x4

The resulting type after applying the * operator.

impl Mul<Vec4x4> for Mat4x4[src]

type Output = Vec4x4

The resulting type after applying the * operator.

impl Mul<f32x4> for Mat4x4[src]

type Output = Mat4x4

The resulting type after applying the * operator.

impl PartialEq<Mat4x4> for Mat4x4[src]

impl StructuralPartialEq for Mat4x4[src]

Auto Trait Implementations

impl RefUnwindSafe for Mat4x4

impl Send for Mat4x4

impl Sync for Mat4x4

impl Unpin for Mat4x4

impl UnwindSafe for Mat4x4

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.