---
title: "atan2"
description: "The angle of the point (x, y) in radians, −π..π."
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#L228"
---

# atan2

The angle of the point (x, y) in radians, −π..π.

```ts
atan2(y: Val, x: Val): Expr
```

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

Takes y first. Turns an offset from a center into an angle around it.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `y` | `Val` |  |
| `x` | `Val` |  |

## Example

```ts
const angle = atan2(delta.member('y'), delta.member('x'))
```

## See also

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