Bouncing balls in a heptagon · ling-2.6-1t
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.
I'll create a physics-based simulation with a rotating heptagon and 20 numbered balls. This requires implementing collision detection for ball-to-ball, ball-to-wall, gravity, friction, and realistic bouncing with spin.
/tmp/ws/index.html (12456 bytes)Successfully wrote 12456 bytes to /tmp/ws/index.html
The simulation is now complete! Here's what I've implemented: ## Features: 1. **Rotating Heptagon** - Spins 360° every 5 seconds with a glowing blue border 2. **20 Numbered Balls** - Each numbered 1-20, with unique colors 3. **Gravity** - Constant downward acceleration (300 px/s²) 4. **Friction** - Velocity damping (0.995) and angular spin friction (0.98) 5. **Ball-to-Ball Collisions** - Full elastic collision detection with: - Overlap resolution - Momentum transfer using impulse physics - Restitution coefficient (0.82) for realistic bounce - Spin transfer based on tangential collision velocity 6. **Ball-to-Wall Collisions** - Collision with rotating heptagon walls: - Point-to-line segment distance calculation - Wall velocity at contact point (due to rotation) accounted for - Tangential friction creates spin - Inward-pointing normal vector calculation 7. **Ball Spin Visualization** - Each ball's number rotates with its angular velocity ## Physics Implementation: - **Collision Detection**: Custom point-to-line distance for walls, distance-based overlap for balls - **Impulse Resolution**: Conservation of momentum with restitution - **Spin Physics**: Angular velocity affects number rotation and transfers during collisions - **Wall Rotation**: Ball velocities are computed relative to the moving wall surface at contact points The simulation runs entirely client-side with no external dependencies - all physics, rendering, and collision detection implemented from scratch.
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
Numbered balls drop and settle in a slowly spinning heptagon; physics runs but no visible reaction to keyboard/mouse input.
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.