# Skeleton kinematics

The dependency-free biped solver: stride cycles with real duty factors, a foot that rolls heel to toe over a planted sole, an equal-segment spine, and arms swinging against the legs.

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

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

## Notes

- No React, no three.js, no dependencies, and nothing is mutated. The stride is worked in the body frame, so a walk cycle and a treadmill are the same drawing.
- Run is a walk with a duty factor below a half. That single number is what produces the moments with no foot down, and pose.grounded reports them rather than hiding them.
- There is no balance, no centre of mass, no ground reaction and no dynamics anywhere in it. Poses, not physics.

## Usage

```tsx
import { solveSkeleton, footRoll, solveLeg } from "@/lib/robocn/skeleton"

const pose = solveSkeleton({ gait: "run", phase: 0.44, stride: 1 })
pose.legs      // hip, knee, ankle, heel, ball, toe, angle, contact
pose.grounded  // false in the moments a run has no foot down
footRoll(0.9)  // { angle, contact, heelLoad, ballLoad, toeLoad }
```

## API

| name | type | default | description |
| --- | --- | --- | --- |
| `solveSkeleton` | `(options?: SkeletonOptions) => SkeletonPose` | — | Pelvis, spine, head, two arms and two legs in world units: x the machine's right, y up, z behind it, floor at y = 0. |
| `strideCycle` | `(gait, t, options?) => StrideSample` | — | One leg's ankle at cycle time t, in the sagittal body frame. The planted foot rolls about its heel, its sole and then its ball. |
| `footRoll` | `(stance: number) => FootRoll` | — | The ankle angle and the load path through one stance: heel at contact, whole sole in the middle, ball and toe at push-off. |
| `footPoints` | `(ankle, angle, proportions?) => FootGeometry` | — | Heel, ball and toe for a rolled ankle. The toe plate is hinged at the ball, so push-off extends that hinge instead of driving the toe through the floor. |
| `solveLeg` | `(hip, foot, femur, tibia) => [Vec2, Vec2, Vec2]` | — | The sagittal two-link leg on its own, knee breaking forward. |
| `spineCurve` | `(options: SpineOptions) => Vec3[]` | — | Vertebra centres from the sacrum to the shoulder line, every segment the same length however far the column leans or twists. |
| `defaultProportions` | `SkeletonProportions` | — | The frame every machine in the family starts from: bone lengths, spans, and the vertebra count. |

## Source

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