# rotm2tform

Convert rotation matrix to homogeneous transformation

## Syntax

``tform = rotm2tform(rotm)``

## Description

example

````tform = rotm2tform(rotm)` converts the rotation matrix `rotm` into a homogeneous transformation matrix `tform`. The input rotation matrix must be in the premultiply form for rotations. When using the transformation matrix, premultiply it by the coordinates to be transformed (as opposed to postmultiplying).```

## Examples

collapse all

```rotm = [1 0 0 ; 0 -1 0; 0 0 -1]; tform = rotm2tform(rotm)```
```tform = 4×4 1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 ```

## Input Arguments

collapse all

Rotation matrix, specified as a 2-by-2-by-n or a 3-by-3-by-n array containing n rotation matrices. Each rotation matrix is either 2-by-2 or 3-by-3 and is orthonormal. The input rotation matrix must be in the premultiplied form for rotations.

Note

Rotation matrices that are not orthonormal can be normalized with the `normalize` function.

2-D rotation matrices are of this form:

3-D rotation matrices are of this form:

Example: `[0 0 1; 0 1 0; -1 0 0]`

## Output Arguments

collapse all

Homogeneous transformation, returned as a 3-by-3-by-n array or 4-by-4-by-n array. n is the number of homogeneous transformations. When using the transformation matrix, premultiply it by the coordinates to be transformed (as opposed to postmultiplying).

2-D homogeneous transformation matrices are of this form:

`$T=\left[\begin{array}{ccc}{r}_{11}& {r}_{12}& {t}_{1}\\ {r}_{21}& {r}_{22}& {t}_{2}\\ 0& 0& 1\end{array}\right]$`

3-D homogeneous transformation matrices are of this form:

`$T=\left[\begin{array}{cccc}{r}_{11}& {r}_{12}& {r}_{13}& {t}_{1}\\ {r}_{21}& {r}_{22}& {r}_{23}& {t}_{2}\\ {r}_{31}& {r}_{32}& {r}_{33}& {t}_{3}\\ 0& 0& 0& 1\end{array}\right]$`

Example: `[0 0 1 0; 0 1 0 0; -1 0 0 0; 0 0 0 1]`

collapse all

### 2-D Homogeneous Transformation Matrix

2-D homogeneous transformation matrices consist of both an SO(2) rotation and an xy-translation.

To read more about SO(2) rotations, see the 2-D Orthonormal Rotation Matrix section of the `so2` object.

The translation is along the x-, y-, and z-axes as a three-element column vector:

`$t=\left[\begin{array}{c}x\\ y\end{array}\right]$`

The SO(2) rotation matrix R is applied to the translation vector t to create the homogeneous translation matrix T. The rotation matrix is present in the upper-left of the transformation matrix as 2-by-2 submatrix, and the translation vector is present as a two-element vector in the last column.

`$T=\left[\begin{array}{cc}R& t\\ {0}_{1×2}& 1\end{array}\right]=\left[\begin{array}{cc}{I}_{2}& t\\ {0}_{1×2}& 1\end{array}\right]·\left[\begin{array}{cc}R& 0\\ {0}_{1×2}& 1\end{array}\right]$`

### 3-D Homogeneous Transformation Matrix

3-D homogeneous transformation matrices consist of both an SO(3) rotation and an xyz-translation.

To read more about SO(3) rotations, see the 3-D Orthonormal Rotation Matrix section of the `so3` object.

The translation is along the x-, y-, and z-axes as a three-element column vector:

`$t=\left[\begin{array}{c}x\\ y\\ z\end{array}\right]$`

The SO(3) rotation matrix R is applied to the translation vector t to create the homogeneous translation matrix T. The rotation matrix is present in the upper-left of the transformation matrix as 3-by-3 submatrix, and the translation vector is present as a three-element vector in the last column.

`$T=\left[\begin{array}{cc}R& t\\ {0}_{1x3}& 1\end{array}\right]=\left[\begin{array}{cc}{I}_{3}& t\\ {0}_{1x3}& 1\end{array}\right]·\left[\begin{array}{cc}R& 0\\ {0}_{1x3}& 1\end{array}\right]$`

## Version History

Introduced in R2015a

expand all