Machines of Wonder · 1 of 4

Draw me Watt's steam engine

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.

▸ The prompt
"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 mechanism in motion A pencil-style technical drawing: on the left, a crank wheel rotates; a connecting rod links the crank pin to a piston that slides in a cylinder on the right. On the right of the canvas, the piston-position-vs-crank-angle curve is plotted in graphite ink, with a moving indicator that tracks the crank's current position. crank · 60 RPM FIG. I. Slider-crank kinematics — after Watt, 1769 —
10 seconds per crank revolution · the indicator rides the curve in lockstep with the rotating crank pin

The mechanism, in three motions

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.

θ = 0
top dead centre

Piston fully out

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.

θ = π
bottom dead centre

Power stroke complete

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.

θ = 2π
cycle close

One full revolution

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.

How Glyph drew it

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.

The Glyph spec JSON

// 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.

Glyph compiler output SVG

Glyph-rendered slider-crank piston-position curve, byte-locked across CI

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.

Your turn — prompts to try

Most mechanical linkages have closed-form kinematics. Name the mechanism and Claude can write the formula.

▸ Mechanism
"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."
▸ Engine cycle
"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."
▸ Locomotive
"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."
▸ Robotics
"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]."

More Machines of Wonder

See all of Life in Glyph ↗ Huygens' Pendulum Wankel Rotor Antikythera