Drag on canvas to aim, release to fire — touch supported
Set the restitution coefficient, gravity, and friction, then drag-and-release to launch balls. Watch momentum conserve (or dissipate) across collisions — the same physics that underpins DEM simulations of granular materials.
Drag on canvas to aim, release to fire — touch supported
For two equal-mass balls, the impulse along the collision normal n̂ (unit vector from ball 1 center to ball 2 center) gives the velocity update:
With e=1 (perfectly elastic), kinetic energy is fully conserved and velocity components are exchanged. With e=0 (perfectly inelastic), the normal relative velocity becomes zero after impact.
The normal velocity component at a wall is negated and multiplied by e. With friction enabled, the tangential velocity is also attenuated proportionally.
This simulator's contact model is the basis of the Discrete Element Method (DEM). Industrial DEM solvers extend it with Hertz contact stiffness, rolling friction, and inter-particle adhesion to model powder compaction, rock crushing, granular flow, and tablet manufacturing — all starting from the same collision equations shown here.
The core principle governing all interactions in this simulator is the conservation of linear momentum for a system of particles. For a collision between two balls, the total momentum before impact equals the total momentum after impact.
$$ m_1 \vec{v}_{1i}+ m_2 \vec{v}_{2i}= m_1 \vec{v}_{1f}+ m_2 \vec{v}_{2f}$$Here, $m$ is mass, $\vec{v}_i$ is initial velocity, and $\vec{v}_f$ is final velocity. This vector equation holds true regardless of the type of collision (elastic or inelastic).
To determine the final velocities, we need a second condition that describes the elasticity of the collision, defined by the coefficient of restitution (COR).
$$ e = \frac{v_{2f}- v_{1f}}{v_{1i}- v_{2i}} $$The COR ($e$) is the slider labeled "Restitution." $e=1$ is a perfectly elastic collision (kinetic energy conserved). $e=0$ is perfectly inelastic (objects stick together). Values between 0 and 1 model real-world, partially bouncy collisions where some kinetic energy is lost.
Vehicle Crash Testing & Safety Design: CAE software uses these exact momentum and restitution principles to simulate car crashes. Engineers adjust the "effective restitution" of crumple zones to manage the transfer of momentum to the passenger cabin, optimizing designs for safety long before building a physical prototype.
Sports Equipment Design: The performance of golf balls, tennis balls, and basketballs is critically dependent on their coefficient of restitution. Designers simulate collisions at different speeds and angles to perfect bounce consistency and energy transfer, much like adjusting the slider in this tool.
Robotics & Automation: Robotic arms that handle and sort items on a conveyor belt must account for collisions. Simulating the momentum transfer with friction and restitution helps program gentle, precise handling to prevent damage to products.
Planetary Science & Orbital Mechanics: The "gravity" and collision modeling here is a 2D simplification of n-body problems. Scientists use advanced versions of these principles to simulate asteroid collisions, moon formation, and spacecraft docking maneuvers, where conserving momentum is fundamental.