---
title: "rotate2"
description: "A 2D point rotated around the origin."
group: "space"
groupTitle: "Shapes, frames & warps"
categoryId: "math"
categorySlug: "math"
categoryTitle: "Math"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/math.ts#L374"
---

# rotate2

A 2D point rotated around the origin.

```ts
rotate2(p: Val, cosA: Val, sinA: Val): Expr
```

Import `math` from `shaders/std` and use `math.rotate2`.

Pass the cosine and sine of the angle in radians, computed once, and the same pair rotates every point.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `p` | `Val` |  |
| `cosA` | `Val` |  |
| `sinA` | `Val` |  |

## Example

```ts
const spun = local(rotate2(delta, cos(angle), sin(angle)), 'spun')
```

## See also

- [`cos`](/docs/primitives/math/cos) — The cosine of an angle in radians, −1..1.
- [`sin`](/docs/primitives/math/sin) — The sine of an angle in radians, −1..1.

## Used by

[FlowingGradient](/docs/components/flowinggradient), [MeshGradient](/docs/components/meshgradient)