#[repr(C)]
pub struct Mat4 { pub cols: [Vec4; 4], }
Expand description

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: [Vec4; 4]

Implementations

Assumes homogeneous 3d coordinates.

Assumes homogeneous 3d coordinates.

Assumes homogeneous 3d coordinates.

Full 4d diagonal matrix.

Full 4d nonuniform scaling matrix.

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.

Create a new rotation matrix from a rotation “around 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.

Create a new rotation matrix from a rotation “around 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.

Create a new rotation matrix from a rotation “around 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.

Create a new rotation matrix from a rotation around the given axis. The axis will be interpreted as a 3d vector. This is here as a convenience function for users coming from other libraries.

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.

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.

Assumes homogeneous 3d coordinates.

Assumes homogeneous 3d coordinates.

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.

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.

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

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.

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

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

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

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

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.

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.

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

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.

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

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Deserialize this value from the given Serde deserializer. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Performs the mutable indexing (container[index]) operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.