# so2

SO(2) rotation

Since R2022b

## Description

The `so2` object represents an SO(2) rotation in 2-D.

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

## Creation

### Syntax

``rotation = so2``
``rotation = so2(rotation)``
``rotation = so2(transformation)``
``rotation = so2(angle,"theta")``

### Description

````rotation = so2` creates an SO(2) rotation representing an identity rotation with no translation.$rotation=\left[\begin{array}{cc}1& 0\\ 0& 1\end{array}\right]$```
````rotation = so2(rotation)` creates an SO(2) rotation `rotation` representing a pure rotation defined by the orthonormal rotation `rotation`.$rotation=\left[\begin{array}{cc}{r}_{11}& {r}_{12}\\ {r}_{21}& {r}_{22}\end{array}\right]$```
````rotation = so2(transformation)` creates an SO(2) rotation from the SE(2) transformation `transformation`.```

example

````rotation = so2(angle,"theta")` creates an SO(2) rotation `rotation` from a rotation angle about the z-axis `angle`.```

Note

If any inputs contain more than one rotation, the output `rotation` is an N-element array of `so2` objects corresponding to each of the N input rotations.

### Input Arguments

expand all

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

If `rotation` is an array, the resulting number of created `so2` objects in the output array is equal to N.

Example: `eye(3)`

Data Types: `single` | `double`

Homogeneous transformation, specified as an `se2` object or an N-element array of `se2` objects. N is the total number of transformations specified.

The output `so2` object contains only the rotational submatrix of the `se2` object.

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

Example: `se2([1 2],"trvec")`

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 `so2` object creates an `so2` object for each angle.

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

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

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
 `so3` SO(3) rotation

## Examples

collapse all

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

`angle = pi/4;`

Create an SO(2) rotation using the angle.

`R = so2(angle,"theta")`
```R = so2 0.7071 -0.7071 0.7071 0.7071 ```

expand all

## Version History

Introduced in R2022b

expand all