# Bear kinematics

The plantigrade solver behind the bears: a rigid sole placed on the floor with the leg solved to the ankle it produces, the base of support those intervals make, and the static share of the weight at each contact.

> 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/bear-kinematics.json
```

Registry item: `bear-kinematics` · [`https://robocn.dev/r/bear-kinematics.json`](https://robocn.dev/r/bear-kinematics.json)

## Notes

- The sole is exactly heel + toe long at every pitch and pivot, and neither end ever goes below the floor — the first two things the solver tests assert.
- The loads are a static weight distribution, not a dynamics solve: no acceleration, no ground reaction, no impulse, no centre of pressure. A load that would come out negative means that foot is being lifted off — the centre of mass is outside the base — so it is clamped to zero and stable already says so.

## Usage

```tsx
import { plantigradeStep, solveSole, solveSupport } from "@/lib/robocn/bear"

const step = plantigradeStep(0.2, { reach: 12, clearance: 8 })
const leg = solveSole({ hip: { x: 0, y: 40 }, plant: step.plant, pivot: step.pivot,
  pitch: step.pitch, femur: 20, tibia: 18, heel: 7, toe: 12, ankle: 5 })
leg.contact // "flat" | "heel" | "toe" | "airborne"
solveSupport([{ id: "hind", span: leg.span }], 6).margin // 1 centred, 0 on an edge
```

## API

| name | type | default | description |
| --- | --- | --- | --- |
| `solveSole` | `(options: SoleOptions) => SolePose` | — | One plantigrade limb, placed by its foot: the sole is rigid and never goes through the floor, the ankle falls out of the placement, and the two links are solved to it. |
| `SoleOptions` | `{ hip, plant, pivot?, pitch?, femur, tibia, heel, toe, ankle, bend?, floor? }` | — | pivot says which point of the sole plant refers to — its heel end, its middle or its toe end — and pitch is the sole's angle, positive toe-up. |
| `SolePose` | `{ hip, knee, ankle, heel, toe, pitch, contact, span, reached }` | — | contact is flat, heel, toe or airborne, read off the geometry rather than copied from pivot; span is the grounded interval, degenerate at a roll and null in the air; reached is false when the hip could not get to the ankle asked for. |
| `solveSupport` | `(contacts, com: number) => SupportPose` | — | The union hull of the grounded intervals, the margin from the centre of mass to the nearest edge (1 dead centre, 0 on an edge, negative outside), and the load at each contact — the minimum-norm solution of loads that sum to 1 and whose weighted mean is the centre of mass, which for two contacts is exactly the lever rule. |
| `plantigradeStep` | `(t, options?) => StepPose` | — | Where one sole is in its own step: heel strike, the roll down, the flat middle of the stance, the roll off the toe, and the swing. A digitigrade foot has one state; this has four. |
| `soleLimits` | `{ strike: 18, off: 26, down: 0.18, lift: 0.72 }` | — | The sole angles a step rolls through, and the fractions of the stance it rolls at. |

## Source

- `src/lib/robocn/bear.ts`
