---
title: "distance"
description: "The distance between two points."
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#L326"
---

# distance

The distance between two points.

```ts
distance(a: Val, b: Val): Expr
```

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

## Parameters

| Name | Type | Notes |
|---|---|---|
| `a` | `Val` |  |
| `b` | `Val` |  |

## Example

```ts
const toPointer = distance(uv, params.ctx.pointer)
```

## See also

- [`length`](/docs/primitives/math/length) — The length of a vector.