# rigid3d

(Not recommended) 3-D rigid geometric transformation using postmultiply convention

Since R2020a

`rigid3d` is not recommended. Use the `rigidtform3d` object instead. For more information, see Compatibility Considerations.

## Description

A `rigid3d` object stores information about a 3-D rigid geometric transformation and enables forward and inverse transformations.

## Creation

### Syntax

``tform = rigid3d``
``tform = rigid3d(t)``
``tform = rigid3d(rot,trans)``

### Description

````tform = rigid3d` creates a default `rigid3d` object that corresponds to an identity transformation.```
````tform = rigid3d(t)` sets the `T` property as the specified 3-D rigid transformation matrix `t`.```

example

````tform = rigid3d(rot,trans)` sets the `Rotation` and `Translation` properties as the specified rotation matrix `rot` and translation vector `trans`, respectively.```

## Properties

expand all

Forward rigid transformation, specified as a 4-by-4 numeric matrix. This matrix must be a homogeneous transformation matrix that satisfies the postmultiply convention given by:

`$\left[\begin{array}{cccc}x& y& z& 1\end{array}\right]=\left[\begin{array}{cccc}u& v& w& 1\end{array}\right]*T$`

`T` has the form

`$\begin{array}{ccccc}\left[{r}_{11}& {r}_{12}& {r}_{13}& 0;& ...\\ {r}_{21}& {r}_{22}& {r}_{23}& 0;& ...\\ {r}_{31}& {r}_{32}& {r}_{33}& 0;& ...\\ {t}_{x}& {t}_{y}& {t}_{z}& 1\right];& \end{array}$`

Data Types: `single` | `double`

Rotation component of the transformation, specified as a 3-by-3 numeric matrix. This rotation matrix satisfies the postmultiply convention given by:

`$\left[\begin{array}{ccc}x& y& z\end{array}\right]=\left[\begin{array}{ccc}u& v& w\end{array}\right]*R$`

Data Types: `single` | `double`

Translation component of the transformation, specified as a 3-element numeric row vector. This translation vector satisfies the convention given by

`$\left[\begin{array}{ccc}x& y& z\end{array}\right]=\left[\begin{array}{ccc}u& v& w\end{array}\right]+t$`

Data Types: `single` | `double`

Dimensionality of the geometric transformation, specified as the value `3`.

## Object Functions

 `invert` Invert geometric transformation `outputLimits` Find output spatial limits given input spatial limits `transformPointsForward` Apply forward geometric transformation `transformPointsInverse` Apply inverse geometric transformation

## Examples

collapse all

Specify an angle of rotation in degrees and create a 3-by-3 rotation matrix.

```theta = 30; rot = [ cosd(theta) sind(theta) 0; ... -sind(theta) cosd(theta) 0; ... 0 0 1];```

Specify the amount of horizontal, vertical, and depthwise translation, respectively.

`trans = [2 3 4];`

Create a `rigid3d` object that performs the rotation and translation.

`tform = rigid3d(rot,trans)`
```tform = rigid3d with properties: Rotation: [3x3 double] Translation: [2 3 4] ```

## Version History

Introduced in R2020a

collapse all

### R2022b: Not recommended

Starting in R2022b, most Image Processing Toolbox™ functions create and perform geometric transformations using the premultiply convention. Accordingly, the `rigid3d` object is not recommended because it uses the postmultiply convention. Although there are no plans to remove the `rigid3d` object at this time, you can streamline your geometric transformation workflows by switching to the `rigidtform3d` object, which supports the premultiply convention. For more information, see Migrate Geometric Transformations to Premultiply Convention.

• Change instances of the function name `rigid3d` to `rigidtform3d`.

• Specify the transformation matrix as the transpose of `T` or the rotation matrix as the transpose of `Rotation`. `T` is either the value of the `T` property of the `rigid3d` object or the transformation matrix used to create the `rigid3d` object. `Rotation` is either the value of the `Rotation` property of the `rigid3d` object or the rotation matrix used to create the `rigid3d` object.

Discouraged UsageRecommended Replacement

This example creates a `rigid3d` object from transformation matrix `T` in the postmultiply convention.

```T = [1 0 0 0; 0 1 0 0; 0 0 1 0; 5 10 -5 1]; tformPost = rigid3d(T);```

This example creates a `rigidtform3d` object from the transpose of matrix `T`.

```T = [1 0 0 0; 0 1 0 0; 0 0 1 0; 5 10 -5 1]; tform = rigidtform3d(T');```

This example starts with a `rigid3d` object called `tformPost` and creates a `rigidtform3d` object from the transpose of the `T` property of `tformPost`.

```T = tformPost.T; tform = rigidtform2d(T');```

This example creates a `rigid3d` object from a rotation matrix `rot` in the postmultiply convention and a translation `trans`.

```theta = 30; rot = [ cosd(theta) sind(theta) 0; ... -sind(theta) cosd(theta) 0; ... 0 0 1]; trans = [5 10 -5]; tformPost = rigid3d(rot,trans);```

This example creates a `rigidtform3d` object from the transpose of the rotation matrix `rot` and a translation `trans`.

```theta = 30; rot = [ cosd(theta) sind(theta) 0; ... -sind(theta) cosd(theta) 0; ... 0 0 1]; trans = [5 10 -5]; tform = rigidtform3d(rot',trans);```