# Matrix3D

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-media3d/struct-matrix3d/

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

```rust
struct Matrix3D
```

A 4x4 transformation of 3D space, with double-precision elements (WPF's
`System.Windows.Media.Media3D.Matrix3D`).

The convention is WPF's: points are row vectors multiplied on the left, `p' = p * M`, so the
translation is the fourth row (`offset_x`, `offset_y`, `offset_z`) and the projective terms are
the fourth column (`m14`, `m24`, `m34`, `m44`). `a * b` is `a` followed by `b`;
`append` multiplies on the right and `prepend` on the
left. The default value is `Matrix3D::IDENTITY`, as in WPF.

The methods that change the matrix take `&mut self`, as WPF's change the structure in place.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L23)

## 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)
- [`offset_x`](#struct_field-offset_x)
- [`offset_y`](#struct_field-offset_y)
- [`offset_z`](#struct_field-offset_z)
- [`m44`](#struct_field-m44)
- [`IDENTITY`](#assoc_const-identity)
- [`new`](#function-new)
- [`set_identity`](#function-set_identity)
- [`is_identity`](#function-is_identity)
- [`is_affine`](#function-is_affine)
- [`determinant`](#function-determinant)
- [`has_inverse`](#function-has_inverse)
- [`invert`](#function-invert)
- [`append`](#function-append)
- [`prepend`](#function-prepend)
- [`rotate`](#function-rotate)
- [`rotate_prepend`](#function-rotate_prepend)
- [`rotate_at`](#function-rotate_at)
- [`rotate_at_prepend`](#function-rotate_at_prepend)
- [`scale`](#function-scale)
- [`scale_prepend`](#function-scale_prepend)
- [`scale_at`](#function-scale_at)
- [`scale_at_prepend`](#function-scale_at_prepend)
- [`translate`](#function-translate)
- [`translate_prepend`](#function-translate_prepend)
- [`transform`](#function-transform)
- [`transform_points`](#function-transform_points)
- [`transform_vector`](#function-transform_vector)
- [`transform_vectors`](#function-transform_vectors)
- [`transform_point4d`](#function-transform_point4d)
- [`transform_points4d`](#function-transform_points4d)
- [`parse`](#function-parse)

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

### m11

```rust
m11: f64
```

Row 1, column 1.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L25)

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

### m12

```rust
m12: f64
```

Row 1, column 2.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L27)

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

### m13

```rust
m13: f64
```

Row 1, column 3.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L29)

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

### m14

```rust
m14: f64
```

Row 1, column 4 (projective).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L31)

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

### m21

```rust
m21: f64
```

Row 2, column 1.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L33)

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

### m22

```rust
m22: f64
```

Row 2, column 2.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L35)

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

### m23

```rust
m23: f64
```

Row 2, column 3.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L37)

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

### m24

```rust
m24: f64
```

Row 2, column 4 (projective).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L39)

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

### m31

```rust
m31: f64
```

Row 3, column 1.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L41)

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

### m32

```rust
m32: f64
```

Row 3, column 2.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L43)

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

### m33

```rust
m33: f64
```

Row 3, column 3.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L45)

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

### m34

```rust
m34: f64
```

Row 3, column 4 (projective).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L47)

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

### offset_x

```rust
offset_x: f64
```

Row 4, column 1: the translation along X.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L49)

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

### offset_y

```rust
offset_y: f64
```

Row 4, column 2: the translation along Y.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L51)

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

### offset_z

```rust
offset_z: f64
```

Row 4, column 3: the translation along Z.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L53)

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

### m44

```rust
m44: f64
```

Row 4, column 4 (projective).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L55)

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

### IDENTITY

```rust
const IDENTITY: Matrix3D
```

The identity transformation (WPF's `Matrix3D.Identity`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L60)

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

### new

```rust
const fn new(m11: f64, m12: f64, m13: f64, m14: f64, m21: f64, m22: f64, m23: f64, m24: f64, m31: f64, m32: f64, m33: f64, m34: f64, offset_x: f64, offset_y: f64, offset_z: f64, m44: f64) -> Self
```

A matrix with the given elements, row by row.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L70)

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

### set_identity

```rust
fn set_identity(self: &mut Self)
```

Makes this the identity.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L110)

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

### is_identity

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

Whether this is the identity, element by element.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L116)

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

### is_affine

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

Whether the matrix is affine: no projective terms (`m14`, `m24`, `m34` zero and `m44` one).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L122)

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

### determinant

```rust
fn determinant(self: &Self) -> f64
```

The determinant: of the upper 3x3 block for an affine matrix, of the whole matrix
otherwise.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L128)

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

### has_inverse

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

Whether the matrix has an inverse: its determinant is not zero within ten machine epsilons.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L140)

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

### invert

```rust
fn invert(self: &mut Self) -> Result<(), Matrix3DError>
```

Replaces the matrix by its inverse; `Matrix3DError::NotInvertible` (and the matrix
unchanged) when it has none (`has_inverse` is false).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L146)

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

### append

```rust
fn append(self: &mut Self, matrix: Matrix3D)
```

Multiplies the matrix by `matrix` on the right: this transformation, then `matrix`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L197)

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

### prepend

```rust
fn prepend(self: &mut Self, matrix: Matrix3D)
```

Multiplies the matrix by `matrix` on the left: `matrix`, then this transformation.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L203)

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

### rotate

```rust
fn rotate(self: &mut Self, quaternion: Quaternion)
```

Appends the rotation of the quaternion about the origin.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L209)

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

### rotate_prepend

```rust
fn rotate_prepend(self: &mut Self, quaternion: Quaternion)
```

Prepends the rotation of the quaternion about the origin.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L215)

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

### rotate_at

```rust
fn rotate_at(self: &mut Self, quaternion: Quaternion, center: Point3D)
```

Appends the rotation of the quaternion about `center`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L221)

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

### rotate_at_prepend

```rust
fn rotate_at_prepend(self: &mut Self, quaternion: Quaternion, center: Point3D)
```

Prepends the rotation of the quaternion about `center`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L227)

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

### scale

```rust
fn scale(self: &mut Self, scale: Vector3D)
```

Appends a scale by the components of the vector, about the origin.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L233)

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

### scale_prepend

```rust
fn scale_prepend(self: &mut Self, scale: Vector3D)
```

Prepends a scale by the components of the vector, about the origin.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L239)

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

### scale_at

```rust
fn scale_at(self: &mut Self, scale: Vector3D, center: Point3D)
```

Appends a scale by the components of the vector, about `center`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L245)

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

### scale_at_prepend

```rust
fn scale_at_prepend(self: &mut Self, scale: Vector3D, center: Point3D)
```

Prepends a scale by the components of the vector, about `center`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L251)

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

### translate

```rust
fn translate(self: &mut Self, offset: Vector3D)
```

Appends a translation by the vector.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L257)

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

### translate_prepend

```rust
fn translate_prepend(self: &mut Self, offset: Vector3D)
```

Prepends a translation by the vector.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L263)

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

### transform

```rust
fn transform(self: &Self, point: Point3D) -> Point3D
```

The point transformed by the matrix, divided by its `w` when the matrix is not affine.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L268)

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

### transform_points

```rust
fn transform_points(self: &Self, points: &mut [Point3D])
```

Transforms the points in place, as `transform`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L285)

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

### transform_vector

```rust
fn transform_vector(self: &Self, vector: Vector3D) -> Vector3D
```

The vector transformed by the matrix: by its upper 3x3 block, so the translation and the
projective terms do not apply.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L293)

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

### transform_vectors

```rust
fn transform_vectors(self: &Self, vectors: &mut [Vector3D])
```

Transforms the vectors in place, as `transform_vector`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L303)

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

### transform_point4d

```rust
fn transform_point4d(self: &Self, point: Point4D) -> Point4D
```

The homogeneous point transformed by the whole matrix, without a divide.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L310)

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

### transform_points4d

```rust
fn transform_points4d(self: &Self, points: &mut [Point4D])
```

Transforms the homogeneous points in place, as
`transform_point4d`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L322)

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

### parse

```rust
fn parse(text: &str) -> Result<Self, FormatError>
```

Parses the text form: `"Identity"`, or the 16 elements row by row (commas, white space or
both between the numbers) in the invariant culture.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/matrix_3d.rs#L330)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `ToString`
- [`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/)
- `ErasedDestructor`
- `IntoEither`
- [`MarkupTyped`](/docs/0.5.0/api/ferroui-base/metadata/trait-markuptyped/)
- `Clone`
- `Copy`
- `Debug`
- `StructuralPartialEq`
- `PartialEq`
- `Default`
- `Mul`
- `MulAssign`
- `FromStr`
- `Display`
- `Mul<Matrix3D>`

## Availability

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