November 11, 2026

Kinetic Shapes: A Physics Sandbox for Bouncing Balls in Spinning Polygons, and the Number That Decides Every Bounce

High-speed photograph of a rubber ball flattened at the instant it hits a hardwood floor

Eighteen small arenas, each a polygon slowly turning on the screen, each holding a handful of balls that fall, strike the walls and rebound. Change one number and the behaviour changes character: balls that settled into a corner start to climb the walls, a tidy swarm turns into a storm, a square becomes a trap. Kinetic Shapes is a browser sandbox built by x9m8 for watching that happen. Every parameter it exposes corresponds to a quantity physicists measure in the real world, and the most important of them is the one that decides how much of a collision survives.

Video: Science Buddies, “The Physics of Bouncing a Ball”

What the sandbox simulates

Gravity, drag, restitution and a rotating container

Each simulation card is a closed polygon, from a triangle to an octagon and a star, plus a few irregular outlines, that rotates at a fixed rate around its centre. Inside it a set of balls obeys four rules on every frame. Gravity adds a constant to each ball’s vertical velocity. A friction term shrinks the velocity by a small fraction, which is a crude stand-in for air drag. When a ball reaches a wall, its velocity is reflected across the wall’s normal and then multiplied by a number between 0 and 1 called restitution. Balls that meet each other exchange momentum.

The three sliders in the header act on every arena at once. Gravity scales the downward pull from zero to several times normal; Speed scales the simulation clock; Rotation scales how fast the containers turn. Each card’s own values (gravity, bounciness, ball count, speed) are printed under it, and the two buttons on a card reset it or expose its configuration.

There is no attempt at realism beyond that. The model is the one physics students write in their first week of a mechanics course, and the point of the sandbox is to see what that model already contains.

Close-up of a golf ball compressing against a driver face at impact

The coefficient of restitution

One ratio, and why a ball never bounces back to where it started

Drop a ball and it does not return to your hand. Some of its kinetic energy goes into sound, heat and deformation at the moment of impact, and the fraction that survives is captured by a single quantity. The coefficient of restitution, e, is the ratio of the object’s rebound speed after the impact to that prior to impact. It is usually a positive, real number between 0 and 1. At e = 1 the collision is perfectly elastic and no kinetic energy is lost; at e = 0 it is perfectly inelastic and the objects stay in contact. A value above 1 would mean a superelastic collision in which stored energy is released during the impact, which is why the sandbox’s “Bounciness” multiplier allows it: push restitution past 1 and the balls gain speed on every wall strike until they are a blur.

The sandbox applies e exactly as the definition says. On impact the velocity component into the wall is reversed and the whole velocity is scaled by the configured restitution, 0.8 in the default preset. Set it near 1 and the balls bounce indefinitely; set it to 0.3 and they slump into whichever wall is currently lowest, then slide as the container rotates out from under them.

Sports bodies regulate the same number

Restitution is not an abstraction. The United States Golf Association tests drivers for it and has placed the upper limit at 0.83. FIBA requires a basketball to rebound to between 1,035 and 1,085 mm when dropped from 1,800 mm, which implies a coefficient of roughly 0.76 to 0.78. A regulation table-tennis ball must bounce up 24 to 26 cm when dropped from 30.5 cm, a coefficient near 0.9. The drop test works because, friction aside, e is the square root of the ratio of one bounce height to the preceding one. Load the “Sticky Pentagon” preset and the “Standard Square” side by side and the difference between a dead ball and a lively one is visible in seconds.

Coloured billiard balls scattering across green felt after a break shot

Shapes that make chaos and shapes that do not

Billiards, Sinai and the stadium

Take gravity to zero and the sandbox becomes a dynamical billiard, the idealized system in which a particle alternates between free motion and specular reflections from a boundary. Mathematicians have studied these tables for a century because the shape of the boundary alone decides whether the motion is predictable. Rectangular or circular tables have integrable equations of motion: a ball’s path can be written down for all time. Birkhoff proved the elliptical table is integrable as well.

Change the boundary slightly and the picture flips. Yakov Sinai introduced a square table with a circular obstacle in the middle whose trajectories are mostly ergodic with a positive Lyapunov exponent: two balls launched a hair apart separate exponentially fast. Leonid Bunimovich showed that the same exponential divergence of orbits appears in a stadium, two semicircles joined by straight sides, a shape with no obstacle at all. Chaos does not need complexity in the walls; it needs the right curvature.

The sandbox’s polygons are a messier case, because they rotate, and a rotating boundary adds and removes energy on each strike depending on which way the wall is moving. The “Zero-G Hexagon” preset is the closest thing to a pure billiard, and even there the slow spin of the container is enough to keep the balls from settling into a repeating path. Watching two presets with identical settings drift apart within a few seconds is the quickest way to see sensitive dependence on initial conditions without a lab.

Long exposure of steel ball bearings tracing light trails inside a rotating hexagonal drum

Presets worth comparing

Eighteen configurations, chosen to isolate one variable at a time

  • Standard Square against High Gravity Triangle: same restitution, triple the pull. The triangle’s acute corners become traps that the square never forms.
  • Zero-G Hexagon against Reverse Gravity: with the pull removed the balls coast forever; invert it and they pile against the ceiling, then spill as the hexagon turns.
  • Fast Spin Octagon against Lazy Spinner: rotation rate is the only difference, and at high spin the walls begin to fling the balls faster than gravity drops them.
  • Swarm, Crowded House and Nano Bots: ball count and size. With dozens of small balls the ball-to-ball collisions dominate and the pattern looks like a gas.
  • Heavy Friction against Hyper Speed: drag versus clock rate, which look similar for a second and then do not.

Use the header sliders to push any of them further. Gravity at zero with Rotation at maximum turns every arena into a centrifuge.

Running the sandbox

The sandbox is a single static page at apps.x9m8.com/Shapes2 with the source on GitHub. It is a React application; the physics is a few hundred lines of plain arithmetic in a canvas loop, with segment-based wall collision so that concave outlines such as the star behave correctly. The “Running” button in the header pauses and resumes every arena together. On a phone the cards stack vertically and all eighteen still run, so a laptop is the better instrument for side-by-side comparison.

For a different kind of rule-driven motion, x9m8’s Cellular Automata Lab runs on a grid instead of a plane, and the Mandelbrot Explorer iterates one equation until it draws a coastline.

Sources

394 Posts

Peter Kalafatis writes and edits X9M8. He holds a bachelor's degree from LIU Post and a master's in Media Studies from The New School, with academic work in the philosophy of science, human behavior, AI, and memetics.

View All Posts

2 Responses to “Kinetic Shapes: A Physics Sandbox for Bouncing Balls in Spinning Polygons, and the Number That Decides Every Bounce”

Leave a Reply

Your email address will not be published. Required fields are marked *

You Missed