#[repr(C)]
pub struct Mat4 { pub x_axis: Vec4, pub y_axis: Vec4, pub z_axis: Vec4, pub w_axis: Vec4, }
Expand description

A 4x4 column major matrix.

This type is 16 byte aligned.

Fields

x_axis: Vec4y_axis: Vec4z_axis: Vec4w_axis: Vec4

Implementations

Creates a 4x4 matrix with all elements set to 0.0.

Creates a 4x4 identity matrix.

Creates a 4x4 matrix from four column vectors.

Creates a 4x4 matrix from a [f32; 16] stored in column major order. If your data is stored in row major you will need to transpose the returned matrix.

Creates a [f32; 16] storing data in column major order. If you require data in row major order transpose the matrix first.

Creates a 4x4 matrix from a [[f32; 4]; 4] stored in column major order. If your data is in row major order you will need to transpose the returned matrix.

Creates a [[f32; 4]; 4] storing data in column major order. If you require data in row major order transpose the matrix first.

Creates a 4x4 homogeneous transformation matrix from the given scale, rotation and translation.

Creates a 4x4 homogeneous transformation matrix from the given translation.

Extracts scale, rotation and translation from self. The input matrix is expected to be a 4x4 homogeneous transformation matrix otherwise the output will be invalid.

Creates a 4x4 homogeneous transformation matrix from the given rotation.

Creates a 4x4 homogeneous transformation matrix from the given translation.

Creates a 4x4 homogeneous transformation matrix containing a rotation around a normalized rotation axis of angle (in radians).

Creates a 4x4 homogeneous transformation matrix containing a rotation around the given Euler angles (in radians).

Creates a 4x4 homogeneous transformation matrix containing a rotation around the x axis of angle (in radians).

Creates a 4x4 homogeneous transformation matrix containing a rotation around the y axis of angle (in radians).

Creates a 4x4 homogeneous transformation matrix containing a rotation around the z axis of angle (in radians).

Creates a 4x4 homogeneous transformation matrix containing the given non-uniform scale.

👎Deprecated since 0.10.0:

please use .x_axis instead

👎Deprecated since 0.10.0:

please use .y_axis instead

👎Deprecated since 0.10.0:

please use .z_axis instead

👎Deprecated since 0.10.0:

please use .w_axis instead

👎Deprecated since 0.10.0:

please use .x_axis instead

👎Deprecated since 0.10.0:

please use .y_axis instead

👎Deprecated since 0.10.0:

please use .z_axis instead

👎Deprecated since 0.10.0:

please use .w_axis instead

👎Deprecated since 0.10.0:

please use .x_axis instead

👎Deprecated since 0.10.0:

please use .y_axis instead

👎Deprecated since 0.10.0:

please use .z_axis instead

👎Deprecated since 0.10.0:

please use .w_axis instead

Returns the transpose of self.

Returns the determinant of self.

Returns the inverse of self.

If the matrix is not invertible the returned matrix will be invalid.

Creates a left-handed view matrix using a camera position, an up direction, and a focal point.

Creates a right-handed view matrix using a camera position, an up direction, and a focal point.

Creates a right-handed perspective projection matrix with [-1,1] depth range. This is the same as the OpenGL gluPerspective function. See https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluPerspective.xml

Creates a left-handed perspective projection matrix with [0,1] depth range.

Creates a right-handed perspective projection matrix with [0,1] depth range.

Creates an infinite left-handed perspective projection matrix with [0,1] depth range.

Creates an infinite left-handed perspective projection matrix with [0,1] depth range.

Creates an infinite right-handed perspective projection matrix with [0,1] depth range.

Creates an infinite reverse right-handed perspective projection matrix with [0,1] depth range.

Creates a right-handed orthographic projection matrix with [-1,1] depth range. This is the same as the OpenGL glOrtho function in OpenGL. See https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glOrtho.xml

Creates a left-handed orthographic projection matrix with [0,1] depth range.

Creates a right-handed orthographic projection matrix with [0,1] depth range.

Transforms a 4D vector.

Multiplies two 4x4 matrices.

Adds two 4x4 matrices.

Subtracts two 4x4 matrices.

Multiplies this matrix by a scalar value.

Transforms the given Vec3 as 3D point.

This is the equivalent of multiplying the Vec3 as a Vec4 where w is 1.0.

Transforms the given Vec3A as 3D point.

This is the equivalent of multiplying the Vec3A as a Vec4 where w is 1.0.

Transforms the give Vec3 as 3D vector.

This is the equivalent of multiplying the Vec3 as a Vec4 where w is 0.0.

Transforms the give Vec3A as 3D vector.

This is the equivalent of multiplying the Vec3A as a Vec4 where w is 0.0.

Returns true if the absolute difference of all elements between self and other is less than or equal to max_abs_diff.

This can be used to compare if two Mat4’s contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against.

For more on floating point comparisons see https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

Converts this type into a mutable reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

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

Formats the value using the given formatter. 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 !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Method which takes an iterator and generates Self from the elements by multiplying the items. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

Method which takes an iterator and generates Self from the elements by “summing up” the items. 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

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

Converts the given value to a String. 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.