# se2

SE(2) homogeneous transformation

Since R2022b

## Description

The `se2` object represents an SE(2) transformation as a 2-D homogeneous transformation matrix consisting of a translation and rotation.

This object acts like a numerical matrix, enabling you to compose poses using multiplication and division.

## Creation

### Syntax

``transformation = se2``
``transformation = se2(rotation)``
``transformation = se2(rotation,translation)``
``transformation = se2(transformation)``
``transformation = se2(angle,"theta")``
``transformation = se2(angle,"theta",translation)``
``transformation = se2(translation,"trvec")``
``transformation = se2(pose,"xytheta")``

### Description

#### Rotation Matrices, Translation Vectors, and Transformation Matrices

````transformation = se2` creates an SE(2) transformation representing an identity rotation with no translation.$transformation=\left[\begin{array}{ccc}1& 0& 0\\ 0& 1& 0\\ 0& 0& 1\end{array}\right]$```
````transformation = se2(rotation)` creates an SE(2) transformation representing a pure rotation defined by the orthonormal rotation `rotation` with no translation. The rotation matrix is represented by the elements in the top left of the `transformation` matrix.$rotation=\left[\begin{array}{cc}{r}_{11}& {r}_{12}\\ {r}_{21}& {r}_{22}\end{array}\right]$$transformation=\left[\begin{array}{ccc}{r}_{11}& {r}_{12}& 0\\ {r}_{21}& {r}_{22}& 0\\ 0& 0& 1\end{array}\right]$```
````transformation = se2(rotation,translation)` creates an SE(2) transformation representing a rotation defined by the orthonormal rotation `rotation` and the translation `translation`. The function applies the rotation matrix first, then the translation vector, to create the transformation.$rotation=\left[\begin{array}{cc}{r}_{11}& {r}_{12}\\ {r}_{21}& {r}_{22}\end{array}\right]$, $translation=\left[\begin{array}{c}{t}_{1}\\ {t}_{2}\end{array}\right]$$transformation=\left[\begin{array}{ccc}{r}_{11}& {r}_{12}& {t}_{1}\\ {r}_{21}& {r}_{22}& {t}_{2}\\ 0& 0& 1\end{array}\right]=\left[\begin{array}{ccc}1& 0& {t}_{1}\\ 0& 1& {t}_{2}\\ 0& 0& 1\end{array}\right]·\left[\begin{array}{ccc}{r}_{11}& {r}_{12}& 0\\ {r}_{21}& {r}_{22}& 0\\ 0& 0& 1\end{array}\right]$```
````transformation = se2(transformation)` creates an SE(2) transformation representing a translation and rotation as defined by the homogeneous transformation `transformation`.```

#### Other 2-D Rotations and Transformation Representations

````transformation = se2(angle,"theta")` creates SE(2) transformations `transformation` from rotations around the z-axis, in radians. The transformation contains zero translation.```

example

````transformation = se2(angle,"theta",translation)` creates SE(2) transformations from rotations around the z-axis, in radians, with translations `translation`.```
````transformation = se2(translation,"trvec")` creates an SE(2) transformation from the translation vector `translation`.```
````transformation = se2(pose,"xytheta")` creates an SE(2) transformation from the 2-D compact pose `pose`.```

### Input Arguments

expand all

Orthonormal rotation, specified as a 2-by-2 matrix, a 2-by-2-by-N array, a scalar `so2` object, or an N-element array of `so2` objects. N is the total number of rotations.

If `rotation` contains more than one rotation and you also specify `translation` at construction, the number of translations in `translation` must be one or equal to the number of rotations in `rotation`. The resulting number of transformation objects is equal to the value of the `translation` or `rotation` argument, whichever is larger.

If `rotation` contains one rotation and you also specify `translation` as an N-by-2 matrix, then the resulting transformations contain the same rotation specified by `rotation` and the corresponding translation vector in `translation`. The resulting number of transformation objects is equal to the number of translations in `translation`.

Example: `eye(2)`

Data Types: `single` | `double`

Translation, specified as an N-by-2 matrix. N is the total number of translations and each translation is of the form [x y].

If `translation` contains more than one translation, the number of rotations in `rotation` must be one or equal to the number of translations in `translation`. The resulting number of created transformation objects is equal to the value of the `translation` or `rotation` argument, whichever is larger.

If you specify more than one translation but only one rotation, the resulting transformations contain the same rotation specified in `rotation` and the corresponding translation in `translation`. The resulting number of created `se2` objects is equal to the value of the `translation`.

Example: `[1 4]`

Data Types: `single` | `double`

Homogeneous transformation, specified as a 3-by-3 matrix, a 3-by-3-N array, a scalar `se3` object, or an N-element array of `se2` objects. N is the total number of transformations specified.

If `transformation` is an array, the resulting number of created `se2` objects is equal to N.

Example: `eye(3)`

Data Types: `single` | `double`

z-axis rotation angle, specified as an N-by-M matrix. Each element of the matrix is an angle, in radians, about the z-axis. The `se2` object creates an `se2` object for each angle.

If `angle` is an N-by-M matrix, the resulting number of created `se2` objects is equal to N.

The rotation angle is counterclockwise positive when you look along the axis toward the origin.

Data Types: `single` | `double`

3-D compact pose, specified as an N-by-3 matrix, where N is the total number of compact poses. Each row is a pose, comprised of an xy position and a rotation about the z-axis, in the form [x y theta]. x, y are the xy-positions and theta is the rotation about the z-axis.

If `pose` is an N-by-3 matrix, the resulting number of created `se2` objects is equal to N.

Data Types: `single` | `double`

## Object Functions

expand all

 `mtimes, *` Transformation or rotation multiplication `mrdivide, /` Transformation or rotation right division `rdivide, ./` Element-wise transformation or rotation right division `times, .*` Element-wise transformation or rotation multiplication
 `interp` Interpolate between transformations `dist` Calculate distance between transformations `normalize` Normalize transformation or rotation matrix `transform` Apply rigid body transformation to points
 `rotm` Extract rotation matrix `trvec` Extract translation vector `tform` Extract homogeneous transformation `theta` Convert transformation or rotation to 2-D rotation angle `xytheta` Convert transformation or rotation to compact 2-D pose representation
 `so2` SO(2) rotation

## Examples

collapse all

Define an angle rotation of `pi/4` and a xyz translation of `[6 4]`.

```angle = pi/6; trvec = [2 1];```

Create an SE(2) transformation using the angle and translation.

`TF = se2(angle,"theta",trvec)`
```TF = se2 0.8660 -0.5000 2.0000 0.5000 0.8660 1.0000 0 0 1.0000 ```

expand all

## Version History

Introduced in R2022b

expand all