Chapter 06 · Inverse Kinematics

The foot must land HERE.
What should the knee do?

Watch a game character walk up uneven stairs. Every step, the engine knows exactly where the foot has to land — but the animation was made on flat ground. Someone has to answer: given where the foot ends up, what angles should the hip and knee take? That question has a name, and by the end of this page you'll drag it around with your mouse.

press play — 90 seconds ↓
▶ watch rgbguy's original — Inverse Kinematics
The lesson · a 90-second movie you can touch

Press play. It explains itself.

Plays like the video — one caption at a time, the picture animating under it — and it pauses when it's your turn. Skip around with the dots or arrow keys. The full lab comes after.

60
skip the lesson ↓
90 seconds · it pauses when it's your turn
Step 1 · Forward first

Forward first (the easy direction)

Here's the classic robot-arm diagram: joints with angles q1, q2, q3, links with fixed lengths, and an End Effector — the hand — at the tip. Given the angles, finding where the hand is is pure plug-and-chug: walk down the chain adding up rotations. That's Forward Kinematics. Turn the knobs and watch the numbers. The HARD question is the reverse.

turn the joints →

Joint angles

70°
-45°
-35°
links (fixed): L1=120 · L2=90 · L3=60
x = L1·cos(q1) + L2·cos(q1+q2) + L3·cos(q1+q2+q3)
x = …
y = …
End Effector: (…, …)
just cos and sin stacked — chapter 07 math
Step 2 · Flip the question

The IK lab — drag the target

Now the reverse: you pick where the hand must be, and the arm has to discover its own angles. Drag the red ✛ anywhere. The solver here is FABRIK — embarrassingly simple: snap the hand to the target and pull the chain backwards, then snap the base home and pull the chain forwards. Repeat until the error is tiny. Turn on show solve steps to literally see it reach.

drag the ✛ target

Segments

Link lengths

120
100
80
60

Show

target: (…, …)
q1 = … · q2 = … · q3 = …
error: … px · iterations: …
Step 3 · Name the two directions

The two directions

This is the whole chapter in one diagram. Going right is Forward Kinematics — you did it with three sliders. Going left is Inverse Kinematics — you did it by dragging a crosshair while an algorithm scrambled to keep up.

Joint Angles (q1, q2, q3)
Forward Kinematics (FK)
cheap, unique answer — plug angles in, one position comes out
Inverse Kinematics (IK)
the useful one — and it has MANY answers
(elbow up? elbow down?)
End Effector (x, y)
your knee solves this in hardware, every step
Step 4 · The payoff

Feet on the stairs

Back to the hook. The body just slides along — nobody animated these legs. Each foot raycasts straight down to find the ground, the swing foot lerps along an arc to its next landing spot (chapter 02!), and a two-bone analytic IK (law of cosines) tells each knee what to do. Planted feet stick while the body passes over the bumps. Press walk.

nobody keyframed this

Walk

L knee: …° · ground: … px
R knee: …° · ground: … px
per leg: d = clamp(|foot−hip|) → law of cosines → knee
this is why feet don't float in good games
Step 5 · Spot it in the wild
where IK is running right now —
  • Character feet & hands. Stairs, slopes, ladders, door handles, grabbing a ledge mid-climb — the animation gets you close, IK snaps the contact point exactly onto the world.
  • Robot arms in factories. "Put the welder tip at (x, y, z)" is the entire job description. The controller solves IK hundreds of times a second to get six joint angles from one target.
  • Rag-doll recovery. A knocked-down character's limbs land wherever physics threw them — IK blends the skeleton from that mess back into the stand-up animation without teleporting the hands.
  • VR hands. The headset only knows where your head and two controllers are. Your entire elbow and shoulder in-game? An IK guess from three targets — and it usually fools you.
See it in 3D · orbit it like Blender

A robot arm solving itself, in 3D

FABRIK doesn't care how many dimensions it works in — the same slide-to-target, slide-to-base trick from above runs here on a 3-bone arm chasing a flying target. Orbit around it and watch the elbow decide.

drag to orbit · scroll to zoom

Target

0.7
backward pass → forward pass → repeat
error: 0.0
The source · rgbguy's original

Watch the video, jump by section

Click any moment on the right — it takes you straight there (in place when this site is served over http, on YouTube when opened as a local file).