# rotate() Function & Examples

Use the rotate() matrix function in Calcul.io. Review its syntax, edit working examples, understand the result, and explore related math functions.

## rotate

#### rotate(w, theta)

#### rotate(w, theta, v)

Try it yourself:

```calculio
rotate([1, 0], pi / 2)
rotate(matrix([1, 0]), unit("35deg"))
rotate([1, 0, 0], unit("90deg"), [0, 0, 1])
rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))
```

---

## rotate(): Rotating Collection Elements

**rotate()** cyclically moves entries in an array or matrix dimension. It is useful for circular buffers, periodic patterns, and shifting a sequence without losing elements.

## Wraparound behavior

A positive or negative offset determines direction, while entries that leave one end reappear at the other. This differs from [resize()](https://calcul.io/function/resize/index.md), which can discard or add positions. Check the shape with [size()](https://calcul.io/function/size/index.md) and choose the intended dimension explicitly.

For one directional shift, compare results with [leftShift()](https://calcul.io/function/leftShift/index.md) only conceptually: bit shifts alter binary digits, whereas rotate rearranges collection values. Use [row()](https://calcul.io/function/row/index.md) or [column()](https://calcul.io/function/column/index.md) to inspect matrix slices.

[All functions](https://calcul.io/functions/index.md)
