The slider-crank mechanism, animated from one English sentence. You asked Claude. Glyph drew it. A piston bobs up and down, a crank converts that to rotation, and the world gets the Industrial Revolution.
"Draw me James Watt's steam engine — the slider-crank mechanism that converts piston motion into rotation. Use the Glyph viz grammar with a parametric function: piston extension is cos(θ) + √(l² − sin²(θ)) where θ is the crank angle and l is the connecting-rod length. Pencil-sketch style. Beautiful enough for a child to follow the crank around; technical enough for a mechanical engineer to recognize the asymmetric power stroke."
— what to say to your AI agent. Claude writes the Glyph spec; the compiler samples the formula 360 times around the crank and renders the piston-position curve.
A slider-crank converts straight-line motion to rotation (or vice versa). The asymmetry of the piston's travel — slow near top dead centre, fast near the middle — is what makes it useful.
The crank pin is on the cylinder axis. Piston extension is at its maximum (r + l). The piston is momentarily stationary — all forward velocity has been spent.
The crank pin is on the opposite side. Piston extension is at its minimum (l − r). The asymmetry between this position and TDC is what gives the engine its working torque.
The piston has completed one out-and-back trip. In a four-stroke engine, every two revolutions produces one power stroke — the rest are intake, compression, and exhaust.
Claude writes the JSON; Glyph samples the piston-position formula 360 times around the crank and emits a polyline. Same spec → byte-identical SVG, every platform, every run.
// slider-crank.json — parametric piston-position curve { "version": "glyph/0.1", "title": "Slider-crank (Watt 1769)", "data": { "function": { "shape": "function", "parameter": { "name": "t", "min": 0, "max": 6.283185307179586, "samples": 360 }, "xExpr": "t", // x_piston = r·cos(θ) + √(l² − r²·sin²(θ)) // here r = 1, l = 3 → range [2, 4] "yExpr": "cos(t) + sqrt(9 - sin(t)*sin(t))" } }, "layers": [{ "mark": "line", "encoding": { "x": { "field": "x" }, "y": { "field": "y" } } }] }
No physics solver needed — the kinematics are closed-form. The non-sinusoidal shape comes from the sqrt, which encodes how the connecting rod tilts relative to the cylinder axis at different crank angles. View on GitHub.
Byte-stable across Ubuntu / macOS / Windows × Node 20 / 22. Asymmetric around θ = π — the upper portion (cos > 0) climbs steeper than the lower (cos < 0) descends, because the sqrt term peaks at π/2 and 3π/2.
Most mechanical linkages have closed-form kinematics. Name the mechanism and Claude can write the formula.
"Draw me the Scotch yoke — same input/output as a slider-crank but with a slotted yoke instead of a connecting rod. Show the piston as a pure cosine. Side-by-side comparison with the Watt slider-crank."
"Show me a four-stroke Otto cycle on a P-V diagram. Intake at constant pressure, adiabatic compression, ignition at top dead centre, power stroke, exhaust. Label each leg."
"Draw the driving wheels of Stephenson's Rocket — three coupled axles with connecting rods. Each wheel's crank pin offset by 90° from the next. Show the rod path over one revolution."
"Plot the end-effector trajectory of a two-link planar robot arm. Link lengths 2 and 1.5. Animate the joints sweeping through θ₁ ∈ [0, π] and θ₂ ∈ [−π/2, π/2]."