Fix figure IK snapping and gate the library on a fail-hard motion checker

Three solver defects made limbs teleport, twist, or windmill: write-back
angles wrapped at ±180 and lerped the long way around; branch flips landed
on configurations the anatomical write-back cannot represent, silently
pulling pinned extremities off their pins; and the degenerate straight-limb
bend plane fell back to the camera axis instead of the anatomical anterior.
solve_limb now verifies each branch reproduces the solved end before
accepting it, resolve unwraps written-back angles toward the pose they
replace, and the degenerate plane comes from the parent's anterior axis.

render.py --check replays every exercise's full tween loop and fails hard
on six invariants (pin fidelity, continuity, wraps, authored-vs-resolved
drift, ground penetration, resolved ROM); --export refuses to ship a
failing exercise. All 66 motions re-authored or retouched to pass: honest
authored angles where pins used to override them silently, grounded feet
on the seated machines, a vertical bench-press bar path, straight-armed
child's pose, a butterfly stretch seated on the mat, and FK arms where
pins forced impossible reaches. MotionSolver.swift mirrors the solver
changes line for line, held by regenerated fixtures.

Claude-Session: https://claude.ai/code/session_01PKptrgbx74peTwHGRxBojv
This commit is contained in:
2026-07-12 00:37:23 -04:00
parent 400601283e
commit 79e75a9127
303 changed files with 3114 additions and 2272 deletions
@@ -3,8 +3,8 @@
<defs>
<linearGradient id="grad-arm_l-0" gradientUnits="userSpaceOnUse" x1="171.0" y1="101.2" x2="171.0" y2="71.9"><stop offset="0" stop-color="#86cfc5"/><stop offset="1" stop-color="#0d9488"/></linearGradient>
<linearGradient id="grad-arm_r-0" gradientUnits="userSpaceOnUse" x1="149.0" y1="101.2" x2="149.0" y2="71.9"><stop offset="0" stop-color="#86cfc5"/><stop offset="1" stop-color="#0d9488"/></linearGradient>
<linearGradient id="grad-leg_l-0" gradientUnits="userSpaceOnUse" x1="167.0" y1="116.0" x2="180.8" y2="118.2"><stop offset="0" stop-color="#a9afba"/><stop offset="1" stop-color="#3a3f4b"/></linearGradient>
<linearGradient id="grad-leg_r-0" gradientUnits="userSpaceOnUse" x1="153.0" y1="116.0" x2="139.2" y2="116.2"><stop offset="0" stop-color="#a9afba"/><stop offset="1" stop-color="#3a3f4b"/></linearGradient>
<linearGradient id="grad-leg_l-0" gradientUnits="userSpaceOnUse" x1="167.0" y1="116.0" x2="179.7" y2="118.1"><stop offset="0" stop-color="#a9afba"/><stop offset="1" stop-color="#3a3f4b"/></linearGradient>
<linearGradient id="grad-leg_r-0" gradientUnits="userSpaceOnUse" x1="153.0" y1="116.0" x2="141.1" y2="116.2"><stop offset="0" stop-color="#a9afba"/><stop offset="1" stop-color="#3a3f4b"/></linearGradient>
</defs>
<path d="M 130.0 141.4 L 130.0 169.4 L 190.0 169.4 L 190.0 141.4 Z" fill="none" stroke="#b9bec9" stroke-width="3" stroke-linejoin="round"/>
<path d="M 148.0 124.0 L 172.0 124.0 L 172.0 124.0 L 148.0 124.0 Z" fill="#c5cad4" stroke="#c5cad4" stroke-width="8" stroke-linecap="round" stroke-linejoin="round"/>
@@ -22,14 +22,14 @@
<path id="pelvisBar" d="M 167.0 116.0 L 160.0 116.0 L 153.0 116.0" stroke="#3a3f4b" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/>
<path id="spine" d="M 160.0 116.0 Q 160.0 108.4 160.0 101.2" stroke="#3a3f4b" stroke-width="6" stroke-linecap="round" stroke-linejoin="round"/>
<g id="leg_l">
<path d="M 167.0 116.0 L 180.8 118.2" stroke="url(#grad-leg_l-0)" stroke-width="5.5" stroke-linecap="round"/>
<path d="M 180.8 118.2 L 180.8 158.1" stroke="#3a3f4b" stroke-width="6" stroke-linecap="round"/>
<path d="M 180.8 158.1 L 184.1 157.7" stroke="#3a3f4b" stroke-width="6" stroke-linecap="round"/>
<path d="M 167.0 116.0 L 179.7 118.1" stroke="url(#grad-leg_l-0)" stroke-width="5.5" stroke-linecap="round"/>
<path d="M 179.7 118.1 L 176.0 157.8" stroke="#3a3f4b" stroke-width="6" stroke-linecap="round"/>
<path d="M 176.0 157.8 L 179.1 157.9" stroke="#3a3f4b" stroke-width="6" stroke-linecap="round"/>
</g>
<g id="leg_r">
<path d="M 153.0 116.0 L 139.2 116.2" stroke="url(#grad-leg_r-0)" stroke-width="5.5" stroke-linecap="round"/>
<path d="M 139.2 116.2 L 139.7 156.1" stroke="#3a3f4b" stroke-width="6" stroke-linecap="round"/>
<path d="M 139.7 156.1 L 136.4 155.7" stroke="#3a3f4b" stroke-width="6" stroke-linecap="round"/>
<path d="M 153.0 116.0 L 141.1 116.2" stroke="url(#grad-leg_r-0)" stroke-width="5.5" stroke-linecap="round"/>
<path d="M 141.1 116.2 L 145.0 156.0" stroke="#3a3f4b" stroke-width="6" stroke-linecap="round"/>
<path d="M 145.0 156.0 L 142.1 155.8" stroke="#3a3f4b" stroke-width="6" stroke-linecap="round"/>
</g>
<path d="M 142.0 41.9 L 156.0 41.9" stroke="#6b7180" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>
<circle cx="142.0" cy="41.9" r="4.5" fill="#6b7180"/>

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

@@ -3,8 +3,8 @@
<defs>
<linearGradient id="grad-arm_l-0" gradientUnits="userSpaceOnUse" x1="171.0" y1="101.2" x2="200.8" y2="100.9"><stop offset="0" stop-color="#86cfc5"/><stop offset="1" stop-color="#0d9488"/></linearGradient>
<linearGradient id="grad-arm_r-0" gradientUnits="userSpaceOnUse" x1="149.0" y1="101.2" x2="119.2" y2="100.9"><stop offset="0" stop-color="#86cfc5"/><stop offset="1" stop-color="#0d9488"/></linearGradient>
<linearGradient id="grad-leg_l-0" gradientUnits="userSpaceOnUse" x1="167.0" y1="116.0" x2="180.8" y2="118.2"><stop offset="0" stop-color="#a9afba"/><stop offset="1" stop-color="#3a3f4b"/></linearGradient>
<linearGradient id="grad-leg_r-0" gradientUnits="userSpaceOnUse" x1="153.0" y1="116.0" x2="139.2" y2="116.2"><stop offset="0" stop-color="#a9afba"/><stop offset="1" stop-color="#3a3f4b"/></linearGradient>
<linearGradient id="grad-leg_l-0" gradientUnits="userSpaceOnUse" x1="167.0" y1="116.0" x2="179.7" y2="118.1"><stop offset="0" stop-color="#a9afba"/><stop offset="1" stop-color="#3a3f4b"/></linearGradient>
<linearGradient id="grad-leg_r-0" gradientUnits="userSpaceOnUse" x1="153.0" y1="116.0" x2="141.1" y2="116.2"><stop offset="0" stop-color="#a9afba"/><stop offset="1" stop-color="#3a3f4b"/></linearGradient>
</defs>
<path d="M 130.0 141.4 L 130.0 169.4 L 190.0 169.4 L 190.0 141.4 Z" fill="none" stroke="#b9bec9" stroke-width="3" stroke-linejoin="round"/>
<path d="M 148.0 124.0 L 172.0 124.0 L 172.0 124.0 L 148.0 124.0 Z" fill="#c5cad4" stroke="#c5cad4" stroke-width="8" stroke-linecap="round" stroke-linejoin="round"/>
@@ -22,14 +22,14 @@
<path id="pelvisBar" d="M 167.0 116.0 L 160.0 116.0 L 153.0 116.0" stroke="#3a3f4b" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/>
<path id="spine" d="M 160.0 116.0 Q 160.0 108.4 160.0 101.2" stroke="#3a3f4b" stroke-width="6" stroke-linecap="round" stroke-linejoin="round"/>
<g id="leg_l">
<path d="M 167.0 116.0 L 180.8 118.2" stroke="url(#grad-leg_l-0)" stroke-width="5.5" stroke-linecap="round"/>
<path d="M 180.8 118.2 L 180.8 158.1" stroke="#3a3f4b" stroke-width="6" stroke-linecap="round"/>
<path d="M 180.8 158.1 L 184.1 157.7" stroke="#3a3f4b" stroke-width="6" stroke-linecap="round"/>
<path d="M 167.0 116.0 L 179.7 118.1" stroke="url(#grad-leg_l-0)" stroke-width="5.5" stroke-linecap="round"/>
<path d="M 179.7 118.1 L 176.0 157.8" stroke="#3a3f4b" stroke-width="6" stroke-linecap="round"/>
<path d="M 176.0 157.8 L 179.1 157.9" stroke="#3a3f4b" stroke-width="6" stroke-linecap="round"/>
</g>
<g id="leg_r">
<path d="M 153.0 116.0 L 139.2 116.2" stroke="url(#grad-leg_r-0)" stroke-width="5.5" stroke-linecap="round"/>
<path d="M 139.2 116.2 L 139.7 156.1" stroke="#3a3f4b" stroke-width="6" stroke-linecap="round"/>
<path d="M 139.7 156.1 L 136.4 155.7" stroke="#3a3f4b" stroke-width="6" stroke-linecap="round"/>
<path d="M 153.0 116.0 L 141.1 116.2" stroke="url(#grad-leg_r-0)" stroke-width="5.5" stroke-linecap="round"/>
<path d="M 141.1 116.2 L 145.0 156.0" stroke="#3a3f4b" stroke-width="6" stroke-linecap="round"/>
<path d="M 145.0 156.0 L 142.1 155.8" stroke="#3a3f4b" stroke-width="6" stroke-linecap="round"/>
</g>
<path d="M 88.8 95.9 L 94.2 83.0" stroke="#6b7180" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>
<circle cx="88.8" cy="95.9" r="4.5" fill="#6b7180"/>

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB