---
title: "FieldSample"
description: "What a field sample carries: the direction away from the source (`rhat`), the `strength`, and the line angle `phi` in radians."
group: "simulation"
groupTitle: "Simulation"
categoryId: "sim.agentForces"
categorySlug: "sim-agentforces"
categoryTitle: "Agent forces"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/sim/agentForces.ts#L597"
---

# FieldSample

What a field sample carries: the direction away from the source (`rhat`), the `strength`, and the line angle `phi` in radians.

```ts
FieldSample(props: { rhat: v2f; strength: number; phi: number; }): { rhat: v2f; strength: number; phi: number; }
```

Import `sim` from `shaders/std` and use `sim.agentForces.FieldSample`.

Build one when writing your own `AgentFieldAt`.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `props` | `{ rhat: v2f; strength: number; phi: number; }` |  |

## Example

```ts
return FieldSample({rhat, strength: fieldStr, phi: std.atan2(B.y, B.x)})
```

## See also

- [`field.dipoleOrRadial`](/docs/primitives/sim-agentforces/field-dipoleorradial) — The field of a magnet at the cursor: a bar magnet along its travel, or a single pole.
- [`torque`](/docs/primitives/sim-agentforces/torque) — The turns an agent that spins in place can feel, for `integrator.orientation2d`.