Matrix4x4
struct · ferroui-base · v0.5.0
struct Matrix4x4
A 4x4 matrix (a three-dimensional transform).
The layout is the one of the reference runtime and is relied on when the
value is passed to a graphics API by address: sixteen consecutive singles
in row order (m11 to m14, then the second, third and fourth row).
Members
m11m12m13m14m21m22m23m24m31m32m33m34m41m42m43m44IDENTITYnewfrom_matrix3x2is_identitytranslationset_translationcreate_from_axis_anglecreate_from_quaternioncreate_from_yaw_pitch_rollcreate_look_atcreate_perspective_field_of_viewcreate_rotation_xcreate_rotation_x_atcreate_rotation_ycreate_rotation_y_atcreate_rotation_zcreate_rotation_z_atcreate_scalecreate_scale_xyzcreate_scale_uniformcreate_scale_atcreate_translationcreate_translation_xyzget_determinantinvertinvert_or_nanlerptranspose
m11
m11: f32
The first element of the first row.
m12
m12: f32
The second element of the first row.
m13
m13: f32
The third element of the first row.
m14
m14: f32
The fourth element of the first row.
m21
m21: f32
The first element of the second row.
m22
m22: f32
The second element of the second row.
m23
m23: f32
The third element of the second row.
m24
m24: f32
The fourth element of the second row.
m31
m31: f32
The first element of the third row.
m32
m32: f32
The second element of the third row.
m33
m33: f32
The third element of the third row.
m34
m34: f32
The fourth element of the third row.
m41
m41: f32
The first element of the fourth row.
m42
m42: f32
The second element of the fourth row.
m43
m43: f32
The third element of the fourth row.
m44
m44: f32
The fourth element of the fourth row.
IDENTITY
const IDENTITY: Matrix4x4
The multiplicative identity matrix.
new
const fn new(m11: f32, m12: f32, m13: f32, m14: f32, m21: f32, m22: f32, m23: f32, m24: f32, m31: f32, m32: f32, m33: f32, m34: f32, m41: f32, m42: f32, m43: f32, m44: f32) -> Self
Creates a 4x4 matrix from the specified components, given in row order.
from_matrix3x2
const fn from_matrix3x2(value: Matrix3x2) -> Self
Creates a 4x4 matrix from the specified 3x2 matrix.
is_identity
fn is_identity(self: &Self) -> bool
Indicates whether the current matrix is the identity matrix.
translation
fn translation(self: &Self) -> Vector3
Gets the translation component of this matrix.
set_translation
fn set_translation(self: &mut Self, value: Vector3)
Sets the translation component of this matrix.
create_from_axis_angle
fn create_from_axis_angle(axis: Vector3, angle: f32) -> Matrix4x4
Creates a matrix that rotates around an arbitrary (unit) vector.
As in the reference runtime, the matrix is built from the quaternion of the rotation.
create_from_quaternion
fn create_from_quaternion(quaternion: Quaternion) -> Matrix4x4
Creates a rotation matrix from the specified quaternion rotation value.
create_from_yaw_pitch_roll
fn create_from_yaw_pitch_roll(yaw: f32, pitch: f32, roll: f32) -> Matrix4x4
Creates a rotation matrix from the specified yaw, pitch, and roll.
create_look_at
fn create_look_at(camera_position: Vector3, camera_target: Vector3, camera_up_vector: Vector3) -> Matrix4x4
Creates a view matrix: a camera at camera_position that looks at
camera_target, with camera_up_vector as the direction that is up
from the camera's point of view (right-handed).
As in the reference runtime, nothing is validated: a target at the position of the camera, or an up vector parallel to the direction of view, gives NaN components.
create_perspective_field_of_view
fn create_perspective_field_of_view(field_of_view: f32, aspect_ratio: f32, near_plane_distance: f32, far_plane_distance: f32) -> Matrix4x4
Creates a perspective projection matrix based on a field of view, aspect ratio, and near and far view plane distances (right-handed, with a depth range of zero to one).
field_of_view is the field of view in the y direction, in radians.
A far plane at positive infinity is accepted and gives the limit of
the matrix (m33 is -1 and m43 is -near_plane_distance).
Panics
Panics where the reference runtime throws an
ArgumentOutOfRangeException: when field_of_view is less than or
equal to zero or greater than or equal to pi, when
near_plane_distance or far_plane_distance is less than or equal to
zero, and when near_plane_distance is greater than or equal to
far_plane_distance.
create_rotation_x
fn create_rotation_x(radians: f32) -> Matrix4x4
Creates a matrix for rotating points around the X axis.
create_rotation_x_at
fn create_rotation_x_at(radians: f32, center_point: Vector3) -> Matrix4x4
Creates a matrix for rotating points around the X axis from a center point.
create_rotation_y
fn create_rotation_y(radians: f32) -> Matrix4x4
Creates a matrix for rotating points around the Y axis.
create_rotation_y_at
fn create_rotation_y_at(radians: f32, center_point: Vector3) -> Matrix4x4
Creates a matrix for rotating points around the Y axis from a center point.
create_rotation_z
fn create_rotation_z(radians: f32) -> Matrix4x4
Creates a matrix for rotating points around the Z axis.
create_rotation_z_at
fn create_rotation_z_at(radians: f32, center_point: Vector3) -> Matrix4x4
Creates a matrix for rotating points around the Z axis from a center point.
create_scale
fn create_scale(scales: Vector3) -> Matrix4x4
Creates a scaling matrix from the specified vector scale.
create_scale_xyz
fn create_scale_xyz(x_scale: f32, y_scale: f32, z_scale: f32) -> Matrix4x4
Creates a scaling matrix from the specified X, Y, and Z components.
create_scale_uniform
fn create_scale_uniform(scale: f32) -> Matrix4x4
Creates a uniform scaling matrix that scales equally on each axis.
create_scale_at
fn create_scale_at(scales: Vector3, center_point: Vector3) -> Matrix4x4
Creates a scaling matrix with a center point.
create_translation
fn create_translation(position: Vector3) -> Matrix4x4
Creates a translation matrix from the specified 3-dimensional vector.
create_translation_xyz
fn create_translation_xyz(x_position: f32, y_position: f32, z_position: f32) -> Matrix4x4
Creates a translation matrix from the specified X, Y, and Z components.
get_determinant
fn get_determinant(self: &Self) -> f32
Calculates the determinant of the current 4x4 matrix.
invert
fn invert(matrix: Matrix4x4) -> Option<Matrix4x4>
Tries to invert the specified matrix. Returns None when the matrix is
singular; see Matrix4x4::invert_or_nan for the value the reference
runtime stores in that case.
invert_or_nan
fn invert_or_nan(matrix: Matrix4x4) -> Matrix4x4
Inverts the specified matrix; a singular matrix gives a matrix whose
components are all NaN (the out value of the reference runtime).
lerp
fn lerp(matrix1: Matrix4x4, matrix2: Matrix4x4, amount: f32) -> Matrix4x4
Performs a linear interpolation from one matrix to a second matrix based on a value that specifies the weighting of the second matrix.
transpose
fn transpose(matrix: Matrix4x4) -> Matrix4x4
Transposes the rows and columns of a matrix.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafePropertyValueAnyValueClassDefaultsBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedToStringErasedDestructorIntoEitherCloneCopyDebugStructuralPartialEqPartialEqDefaultAddSubNegMulMul<f32>DisplayFrom<Matrix4x4>ExpressionVariantValueBatchValue
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.