Bouncing balls in a heptagon · claude-opus-4.8
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 · 4 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.
thinking
I'm building an interactive physics simulation with 20 numbered balls dropping from the center of a spinning heptagon, implementing gravity, friction, ball-to-ball collisions, and bouncing off the rotating walls, with the ball numbers rotating to show their spin. Writing physics engine...
/workspace/index.html (8283 bytes)Successfully wrote 8283 bytes to /workspace/index.html
Created `/workspace/index.html`. It's a self-contained single file with everything inline. Highlights: - **20 numbered balls** spawn from the heptagon's center with slight random velocities. - **Spinning heptagon**: rotates 360° every 5 seconds (`SPIN = 2π/5` rad/s), vertices recomputed each frame. - **Gravity + friction**: constant downward acceleration plus per-step velocity damping. - **Self-implemented collision detection**: - *Ball–wall*: closest point on each edge segment, inward-normal reflection with restitution. Wall velocity (`ω × r`) is factored in so balls get kicked by the moving edges realistically. - *Ball–ball*: pairwise distance check with positional separation and normal impulse resolution. - **Spin visualization**: each ball's number (plus a small tick mark) rotates based on angular velocity gained from tangential friction during collisions. - Uses sub-stepping and multiple solver iterations for stability. Open it in a browser to watch it run.
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 with 20 numbered balls falling and settling under gravity; rotation and physics visible, but no interactive input response since it's a passive simulation.
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.