# Matrix4x4

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/numerics/struct-matrix4x4/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

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

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L16)

## Members

- [`m11`](#struct_field-m11)
- [`m12`](#struct_field-m12)
- [`m13`](#struct_field-m13)
- [`m14`](#struct_field-m14)
- [`m21`](#struct_field-m21)
- [`m22`](#struct_field-m22)
- [`m23`](#struct_field-m23)
- [`m24`](#struct_field-m24)
- [`m31`](#struct_field-m31)
- [`m32`](#struct_field-m32)
- [`m33`](#struct_field-m33)
- [`m34`](#struct_field-m34)
- [`m41`](#struct_field-m41)
- [`m42`](#struct_field-m42)
- [`m43`](#struct_field-m43)
- [`m44`](#struct_field-m44)
- [`IDENTITY`](#assoc_const-identity)
- [`new`](#function-new)
- [`from_matrix3x2`](#function-from_matrix3x2)
- [`is_identity`](#function-is_identity)
- [`translation`](#function-translation)
- [`set_translation`](#function-set_translation)
- [`create_from_axis_angle`](#function-create_from_axis_angle)
- [`create_from_quaternion`](#function-create_from_quaternion)
- [`create_from_yaw_pitch_roll`](#function-create_from_yaw_pitch_roll)
- [`create_look_at`](#function-create_look_at)
- [`create_perspective_field_of_view`](#function-create_perspective_field_of_view)
- [`create_rotation_x`](#function-create_rotation_x)
- [`create_rotation_x_at`](#function-create_rotation_x_at)
- [`create_rotation_y`](#function-create_rotation_y)
- [`create_rotation_y_at`](#function-create_rotation_y_at)
- [`create_rotation_z`](#function-create_rotation_z)
- [`create_rotation_z_at`](#function-create_rotation_z_at)
- [`create_scale`](#function-create_scale)
- [`create_scale_xyz`](#function-create_scale_xyz)
- [`create_scale_uniform`](#function-create_scale_uniform)
- [`create_scale_at`](#function-create_scale_at)
- [`create_translation`](#function-create_translation)
- [`create_translation_xyz`](#function-create_translation_xyz)
- [`get_determinant`](#function-get_determinant)
- [`invert`](#function-invert)
- [`invert_or_nan`](#function-invert_or_nan)
- [`lerp`](#function-lerp)
- [`transpose`](#function-transpose)

<a id="struct_field-m11"></a>

### m11

```rust
m11: f32
```

The first element of the first row.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L18)

<a id="struct_field-m12"></a>

### m12

```rust
m12: f32
```

The second element of the first row.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L20)

<a id="struct_field-m13"></a>

### m13

```rust
m13: f32
```

The third element of the first row.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L22)

<a id="struct_field-m14"></a>

### m14

```rust
m14: f32
```

The fourth element of the first row.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L24)

<a id="struct_field-m21"></a>

### m21

```rust
m21: f32
```

The first element of the second row.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L26)

<a id="struct_field-m22"></a>

### m22

```rust
m22: f32
```

The second element of the second row.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L28)

<a id="struct_field-m23"></a>

### m23

```rust
m23: f32
```

The third element of the second row.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L30)

<a id="struct_field-m24"></a>

### m24

```rust
m24: f32
```

The fourth element of the second row.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L32)

<a id="struct_field-m31"></a>

### m31

```rust
m31: f32
```

The first element of the third row.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L34)

<a id="struct_field-m32"></a>

### m32

```rust
m32: f32
```

The second element of the third row.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L36)

<a id="struct_field-m33"></a>

### m33

```rust
m33: f32
```

The third element of the third row.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L38)

<a id="struct_field-m34"></a>

### m34

```rust
m34: f32
```

The fourth element of the third row.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L40)

<a id="struct_field-m41"></a>

### m41

```rust
m41: f32
```

The first element of the fourth row.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L42)

<a id="struct_field-m42"></a>

### m42

```rust
m42: f32
```

The second element of the fourth row.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L44)

<a id="struct_field-m43"></a>

### m43

```rust
m43: f32
```

The third element of the fourth row.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L46)

<a id="struct_field-m44"></a>

### m44

```rust
m44: f32
```

The fourth element of the fourth row.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L48)

<a id="assoc_const-identity"></a>

### IDENTITY

```rust
const IDENTITY: Matrix4x4
```

The multiplicative identity matrix.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L53)

<a id="function-new"></a>

### new

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L60)

<a id="function-from_matrix3x2"></a>

### from_matrix3x2

```rust
const fn from_matrix3x2(value: Matrix3x2) -> Self
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L100)

<a id="function-is_identity"></a>

### is_identity

```rust
fn is_identity(self: &Self) -> bool
```

Indicates whether the current matrix is the identity matrix.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L109)

<a id="function-translation"></a>

### translation

```rust
fn translation(self: &Self) -> Vector3
```

Gets the translation component of this matrix.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L115)

<a id="function-set_translation"></a>

### set_translation

```rust
fn set_translation(self: &mut Self, value: Vector3)
```

Sets the translation component of this matrix.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L121)

<a id="function-create_from_axis_angle"></a>

### create_from_axis_angle

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L131)

<a id="function-create_from_quaternion"></a>

### create_from_quaternion

```rust
fn create_from_quaternion(quaternion: Quaternion) -> Matrix4x4
```

Creates a rotation matrix from the specified quaternion rotation value.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L137)

<a id="function-create_from_yaw_pitch_roll"></a>

### create_from_yaw_pitch_roll

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L168)

<a id="function-create_look_at"></a>

### create_look_at

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L180)

<a id="function-create_perspective_field_of_view"></a>

### create_perspective_field_of_view

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L224)

<a id="function-create_rotation_x"></a>

### create_rotation_x

```rust
fn create_rotation_x(radians: f32) -> Matrix4x4
```

Creates a matrix for rotating points around the X axis.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L281)

<a id="function-create_rotation_x_at"></a>

### create_rotation_x_at

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L298)

<a id="function-create_rotation_y"></a>

### create_rotation_y

```rust
fn create_rotation_y(radians: f32) -> Matrix4x4
```

Creates a matrix for rotating points around the Y axis.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L320)

<a id="function-create_rotation_y_at"></a>

### create_rotation_y_at

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L337)

<a id="function-create_rotation_z"></a>

### create_rotation_z

```rust
fn create_rotation_z(radians: f32) -> Matrix4x4
```

Creates a matrix for rotating points around the Z axis.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L359)

<a id="function-create_rotation_z_at"></a>

### create_rotation_z_at

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L376)

<a id="function-create_scale"></a>

### create_scale

```rust
fn create_scale(scales: Vector3) -> Matrix4x4
```

Creates a scaling matrix from the specified vector scale.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L399)

<a id="function-create_scale_xyz"></a>

### create_scale_xyz

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L405)

<a id="function-create_scale_uniform"></a>

### create_scale_uniform

```rust
fn create_scale_uniform(scale: f32) -> Matrix4x4
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L415)

<a id="function-create_scale_at"></a>

### create_scale_at

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

Creates a scaling matrix with a center point.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L420)

<a id="function-create_translation"></a>

### create_translation

```rust
fn create_translation(position: Vector3) -> Matrix4x4
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L437)

<a id="function-create_translation_xyz"></a>

### create_translation_xyz

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L443)

<a id="function-get_determinant"></a>

### get_determinant

```rust
fn get_determinant(self: &Self) -> f32
```

Calculates the determinant of the current 4x4 matrix.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L452)

<a id="function-invert"></a>

### invert

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L490)

<a id="function-invert_or_nan"></a>

### invert_or_nan

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L571)

<a id="function-lerp"></a>

### lerp

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L580)

<a id="function-transpose"></a>

### transpose

```rust
fn transpose(matrix: Matrix4x4) -> Matrix4x4
```

Transposes the rows and columns of a matrix.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/matrix4x4.rs#L602)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `ToString`
- `ErasedDestructor`
- `IntoEither`
- `Clone`
- `Copy`
- `Debug`
- `StructuralPartialEq`
- `PartialEq`
- `Default`
- `Add`
- `Sub`
- `Neg`
- `Mul`
- `Mul<f32>`
- `Display`
- `From<Matrix4x4>`
- `ExpressionVariantValue`
- `BatchValue`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
