Bouncing balls in a heptagon · muse-spark-1.2
Show 20 numbered balls (1 to 20) dropping from the center of a heptagon that spins 360 degrees every 5 seconds. The balls are affected by gravity and friction, collide with each other, and bounce realistically off the rotating walls; show each ball's spin via the rotation of its number. Implement all collision detection yourself.
transcript · 6 messages
Show 20 numbered balls (1 to 20) dropping from the center of a heptagon that spins 360 degrees every 5 seconds. The balls are affected by gravity and friction, collide with each other, and bounce realistically off the rotating walls; show each ball's spin via the rotation of its number. Implement all collision detection yourself.
index.html (18241 bytes)Successfully wrote 18241 bytes to index.html
{"command":"ls -lh index.html && head -n 5 index.html"}-rw-r--r--. 1 node node 18K Aug 13 01:24 index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
Single-page app written to `index.html` — self-contained, no external resources. **Physics highlights:** - Heptagon `Ω = 2π/5 rad/s` (360°/5s), vertices recomputed each sub-step - Custom wall collision: closest-point on 7 rotating segments, inward normal, moving-wall velocity `(-Ω·ry, Ω·rx)` for impulse + `REST_WALL=0.78` + friction harvesting tangential velocity into spin `w` - Custom ball-ball: pairwise `O(n²)` distance check, penetration separation + restitution `0.88` + Coulomb friction converting tangential slip into opposite spins - Gravity `950px/s²`, air/angular damping, 2× sub-steps for stability - Each ball's number is drawn inside the rotated ball (`ctx.rotate(b.ang)`), making spin directly visible plus a tick mark.
TAKE IT TO CODE
A single self-contained HTML file — copy it and open in any browser, or reuse the prompt with your own pi-agent run.
RUN
EVALUATION
Heptagon rotates continuously, balls fall, bounce, and settle at bottom with visible numbers; no interactive input changes behavior.
Vision grade · anthropic/claude-sonnet-5
MEASUREMENTS
Raw readings from the capture, not a verdict — the grade above is the only judgement. Percentages are how much of the screen changed; the measure under-reports sparse motion on a dark background.