# useRobotArm

Animated pose for a link chain. It eases the tip toward its goal, solves seeded with the previous frame, and stops the loop once the pose settles.

> For the complete index, see [llms.txt](https://robocn.dev/llms.txt). A Markdown version of any page is available by appending `.md` to its URL or by sending an `Accept: text/markdown` header.

## Install

```bash
bunx --bun shadcn@latest add https://robocn.dev/r/use-robot-arm.json
```

Registry item: `use-robot-arm` · [`https://robocn.dev/r/use-robot-arm.json`](https://robocn.dev/r/use-robot-arm.json)

## Usage

```tsx
const pose = useRobotArm({
  links: [30, 24, 16],
  target: (clock) => ({ x: Math.cos(clock) * 30, y: 30 }),
  behavior: "idle",
})

pose.joints // Vec2[], shoulder to tip
pose.angles // degrees, relative to the previous segment
```

## API

| name | type | default | description |
| --- | --- | --- | --- |
| `useRobotArm` | `(options) => RobotArmPose` | — | joints, tip, angles and whether the tip is still chasing its goal. |
| `useEasedPoint` | `(target, start, options?) => EasedPoint` | — | The easing half on its own, for machines with no chain to solve. Returns point, clock and moving. Set perAxis: true to move each axis independently at the configured feed rate. |
| `robotRestTarget` | `(root, links) => Vec2` | — | Where an arm parks when it has nothing to chase. |

## Source

- `src/hooks/use-robot-arm.ts`
