> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/holoscan/sdk-user-guide/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/holoscan/sdk-user-guide/_mcp/server.

# holoscan::SO2

> Class representing 2D rotations using the SO(2) group.

```cpp showLineNumbers={false}
template <typename K>
class SO2
```

Class representing 2D rotations using the SO(2) group.

This class represents rotations in 2D space as elements of the special orthogonal group SO(2). Internally, rotations are stored as normalized direction vectors (cos, sin) to avoid trigonometric function calls during composition and transformation operations.

```cpp showLineNumbers={false}
#include <holoscan/so2.hpp>
```

**Template parameters**

**`K`** `typename`

Scalar type (typically float or double).

---

---

## Constructors

### SO2 \[#so2]

```cpp showLineNumbers={false}
holoscan::SO2<K>::SO2()
```

Default constructor creates an undefined rotation.

Use identity() to create the identity rotation.

---

## Methods

### cos \[#cos]

```cpp showLineNumbers={false}
K holoscan::SO2<K>::cos() const
```

Get the cosine of the rotation angle.

This is a simple getter and does not call trigonometric functions.

**Returns:** Cosine of the rotation angle.

### sin \[#sin]

```cpp showLineNumbers={false}
K holoscan::SO2<K>::sin() const
```

Get the sine of the rotation angle.

This is a simple getter and does not call trigonometric functions.

**Returns:** Sine of the rotation angle.

### as\_direction \[#asdirection]

```cpp showLineNumbers={false}
const Vector2<K> & holoscan::SO2<K>::as_direction() const
```

Get the cos and sin of the rotation angle as a direction vector.

**Returns:** Direction vector (cos, sin).

### angle \[#angle]

```cpp showLineNumbers={false}
K holoscan::SO2<K>::angle() const
```

Get the rotation angle in range \[-π, π].

This uses a call to a trigonometric function.

**Returns:** Rotation angle in radians.

### matrix \[#matrix]

```cpp showLineNumbers={false}
Matrix2<K> holoscan::SO2<K>::matrix() const
```

Get the 2×2 rotation matrix representation.

**Returns:** 2×2 rotation matrix.

### inverse \[#inverse]

```cpp showLineNumbers={false}
SO2 holoscan::SO2<K>::inverse() const
```

Get the inverse rotation.

**Returns:** Inverse rotation.

### cast \[#cast]

#### Const (1)

```cpp showLineNumbers={false}
template <typename S>
SO2<S> holoscan::SO2<K>::cast() const
```

Cast to a different scalar type.

**Returns:** Rotation cast to the target type.

**Template parameters**

**`S`** `typename`

Target scalar type.

---

#### Const (2)

```cpp showLineNumbers={false}
template <typename S>
const SO2 & holoscan::SO2<K>::cast() const
```

Cast to the same scalar type (no-op).

**Returns:** Reference to this rotation.

**Template parameters**

**`S`** `typename`

Target scalar type (same as K).

---

---

## Static methods

### identity \[#identity]

```cpp showLineNumbers={false}
static SO2 holoscan::SO2<K>::identity()
```

Create the identity rotation.

**Returns:** Identity rotation (no rotation).

### from\_angle \[#fromangle]

```cpp showLineNumbers={false}
static SO2 holoscan::SO2<K>::from_angle(
    K angle
)
```

Create rotation from an angle.

This uses calls to trigonometric functions.

**Returns:** Rotation representing the given angle.

**Parameters**

**`angle`** `K`

Rotation angle in radians.

---

### from\_direction \[#fromdirection]

#### Overload 1

```cpp showLineNumbers={false}
static SO2 holoscan::SO2<K>::from_direction(
    const Vector2<K> &direction
)
```

Create rotation from a not necessarily normalized direction vector.

**Returns:** Rotation aligned with the given direction.

**Parameters**

**`direction`** `const Vector2<K> &`

Direction vector (will be normalized internally).

---

#### Create rotation from direction components

```cpp showLineNumbers={false}
static SO2 holoscan::SO2<K>::from_direction(
    K dx,
    K dy
)
```

Create rotation from direction components.

**Returns:** Rotation aligned with the given direction.

**Parameters**

**`dx`** `K`

X component of direction vector.

---

**`dy`** `K`

Y component of direction vector.

---

### from\_normalized \[#fromnormalized]

#### Overload 1

```cpp showLineNumbers={false}
static SO2 holoscan::SO2<K>::from_normalized(
    const Vector2<K> &cos_sin
)
```

Create rotation from a normalized cos/sin direction vector.

**Returns:** Rotation represented by the given cos/sin values.

**Parameters**

**`cos_sin`** `const Vector2<K> &`

Normalized direction vector (cos, sin).

---

#### Create rotation from normalized cos and sin values

```cpp showLineNumbers={false}
static SO2 holoscan::SO2<K>::from_normalized(
    K cos_angle,
    K sin_angle
)
```

Create rotation from normalized cos and sin values.

**Returns:** Rotation represented by the given cos/sin values.

**Parameters**

**`cos_angle`** `K`

Cosine of the rotation angle.

---

**`sin_angle`** `K`

Sine of the rotation angle.

---

---

## Types

### Typedefs

| Name     | Definition |
| -------- | ---------- |
| `Scalar` | `K`        |

---

## Member variables

| Name                          | Type           | Description                                             |
| ----------------------------- | -------------- | ------------------------------------------------------- |
| `kDimension` static constexpr | `int`          |                                                         |
| `cos_sin_`                    | `Vector2< K >` | Internal representation as (cos, sin) direction vector. |