Skip to main content

Matrix4x4

Struct Matrix4x4 

Source
#[repr(C)]
pub struct Matrix4x4 {
Show 16 fields pub m11: f32, pub m12: f32, pub m13: f32, pub m14: f32, pub m21: f32, pub m22: f32, pub m23: f32, pub m24: f32, pub m31: f32, pub m32: f32, pub m33: f32, pub m34: f32, pub m41: f32, pub m42: f32, pub m43: f32, pub m44: f32,
}
Expand description

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).

Fields§

§m11: f32

The first element of the first row.

§m12: f32

The second element of the first row.

§m13: f32

The third element of the first row.

§m14: f32

The fourth element of the first row.

§m21: f32

The first element of the second row.

§m22: f32

The second element of the second row.

§m23: f32

The third element of the second row.

§m24: f32

The fourth element of the second row.

§m31: f32

The first element of the third row.

§m32: f32

The second element of the third row.

§m33: f32

The third element of the third row.

§m34: f32

The fourth element of the third row.

§m41: f32

The first element of the fourth row.

§m42: f32

The second element of the fourth row.

§m43: f32

The third element of the fourth row.

§m44: f32

The fourth element of the fourth row.

Implementations§

Source§

impl Matrix4x4

Source

pub const IDENTITY: Matrix4x4

The multiplicative identity matrix.

Source

pub 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.

Source

pub const fn from_matrix3x2(value: Matrix3x2) -> Self

Creates a 4x4 matrix from the specified 3x2 matrix.

Source

pub fn is_identity(&self) -> bool

Indicates whether the current matrix is the identity matrix.

Source

pub fn translation(&self) -> Vector3

Gets the translation component of this matrix.

Source

pub fn set_translation(&mut self, value: Vector3)

Sets the translation component of this matrix.

Source

pub 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.

Source

pub fn create_from_quaternion(quaternion: Quaternion) -> Matrix4x4

Creates a rotation matrix from the specified quaternion rotation value.

Source

pub fn create_from_yaw_pitch_roll(yaw: f32, pitch: f32, roll: f32) -> Matrix4x4

Creates a rotation matrix from the specified yaw, pitch, and roll.

Source

pub 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.

Source

pub 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.

Source

pub fn create_rotation_x(radians: f32) -> Matrix4x4

Creates a matrix for rotating points around the X axis.

Source

pub 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.

Source

pub fn create_rotation_y(radians: f32) -> Matrix4x4

Creates a matrix for rotating points around the Y axis.

Source

pub 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.

Source

pub fn create_rotation_z(radians: f32) -> Matrix4x4

Creates a matrix for rotating points around the Z axis.

Source

pub 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.

Source

pub fn create_scale(scales: Vector3) -> Matrix4x4

Creates a scaling matrix from the specified vector scale.

Source

pub 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.

Source

pub fn create_scale_uniform(scale: f32) -> Matrix4x4

Creates a uniform scaling matrix that scales equally on each axis.

Source

pub fn create_scale_at(scales: Vector3, center_point: Vector3) -> Matrix4x4

Creates a scaling matrix with a center point.

Source

pub fn create_translation(position: Vector3) -> Matrix4x4

Creates a translation matrix from the specified 3-dimensional vector.

Source

pub 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.

Source

pub fn get_determinant(&self) -> f32

Calculates the determinant of the current 4x4 matrix.

Source

pub 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.

Source

pub 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).

Source

pub 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.

Source

pub fn transpose(matrix: Matrix4x4) -> Matrix4x4

Transposes the rows and columns of a matrix.

Trait Implementations§

Source§

impl Add for Matrix4x4

Source§

type Output = Matrix4x4

The resulting type after applying the + operator.
Source§

fn add(self, value2: Matrix4x4) -> Matrix4x4

Performs the + operation. Read more
Source§

impl BatchValue for Matrix4x4

Source§

fn write_to(&self, out: &mut Vec<u8>)

Source§

fn read_from(input: &mut BatchValueReader<'_>) -> Self

Source§

impl Clone for Matrix4x4

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Matrix4x4

Source§

impl Debug for Matrix4x4

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Matrix4x4

Source§

fn default() -> Self

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

impl Display for Matrix4x4

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ExpressionVariantValue for Matrix4x4

Source§

const FFI_VARIANT_TYPE: Option<VariantType>

The variant type a foreign function parameter of this type is matched against, or None when the type cannot be a foreign function parameter.
Source§

fn try_from_variant(v: &ExpressionVariant) -> Option<Self>

Source§

fn into_variant(self) -> ExpressionVariant

Source§

impl From<Matrix4x4> for ExpressionVariant

Source§

fn from(value: Matrix4x4) -> ExpressionVariant

Converts to this type from the input type.
Source§

impl Mul for Matrix4x4

Source§

type Output = Matrix4x4

The resulting type after applying the * operator.
Source§

fn mul(self, value2: Matrix4x4) -> Matrix4x4

Performs the * operation. Read more
Source§

impl Mul<f32> for Matrix4x4

Multiplies every component by a scalar.

Source§

type Output = Matrix4x4

The resulting type after applying the * operator.
Source§

fn mul(self, value2: f32) -> Matrix4x4

Performs the * operation. Read more
Source§

impl Neg for Matrix4x4

Source§

type Output = Matrix4x4

The resulting type after applying the - operator.
Source§

fn neg(self) -> Matrix4x4

Performs the unary - operation. Read more
Source§

impl PartialEq for Matrix4x4

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Matrix4x4

Source§

impl Sub for Matrix4x4

Source§

type Output = Matrix4x4

The resulting type after applying the - operator.
Source§

fn sub(self, value2: Matrix4x4) -> Matrix4x4

Performs the - operation. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnyValue for T
where T: PartialEq + 'static,

Source§

fn any_value_as_any(&self) -> &(dyn Any + 'static)

Source§

fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool

Source§

fn any_value_type_name(&self) -> &'static str

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> PropertyValue for T
where T: Clone + PartialEq + 'static,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.