User Rating 0.0
Total Usage 0 times
Physics
New Body
Presets
Controls
Stats
Bodies0
KE0
Momentum0
Collisions0
FPS0
Click canvas to spawn. Drag bodies to move.
Is this tool helpful?

Your feedback helps us improve.

About

Collision response calculations require precise impulse resolution. A miscalculated coefficient of restitution e produces energy that either vanishes or appears from nowhere, breaking conservation laws and yielding physically meaningless results. This simulator solves the two-body collision problem using impulse-based response derived from conservation of linear momentum and the restitution equation vrel = e vrel. It handles circle-circle and circle-wall interactions with positional correction to prevent tunneling at high velocities.

The engine uses semi-implicit Euler integration and a spatial hash grid for broad-phase detection, scaling from a handful of bodies to several hundred without frame drops. Kinetic energy is tracked in real time so you can verify conservation during elastic collisions or observe energy dissipation when e < 1. Note: the simulation assumes 2D rigid bodies with no rotational inertia. Friction and angular momentum are not modeled. At very high speeds or very small radii, tunneling may still occur due to discrete time stepping.

collision simulator physics engine 2d physics elastic collision momentum conservation interactive simulation particle physics

Formulas

The impulse magnitude J along the collision normal n for two colliding circles:

J = (1 + e) vrel n1m1 + 1m2

Post-collision velocities are then updated:

v1 = v1 + Jm1 n
v2 = v2 Jm2 n

Semi-implicit Euler integration advances state each frame:

v(t + Δt) = v(t) + a(t) Δt
x(t + Δt) = x(t) + v(t + Δt) Δt

Where e = coefficient of restitution, vrel = relative velocity of approach (v1 v2), n = unit collision normal from body 2 to body 1, m1, m2 = masses, a = acceleration due to gravity and external forces, Δt = fixed time step.

Reference Data

ParameterSymbolTypical RangeUnitNotes
Coefficient of Restitutione0 - 1 - 1 = perfectly elastic, 0 = perfectly inelastic
Steel on Steele0.80 - 0.95 - Hardened steel balls
Glass on Glasse0.93 - 0.97 - Tempered glass spheres
Rubber on Concretee0.75 - 0.85 - Standard basketball bounce
Tennis Ball on Courte0.70 - 0.75 - ITF regulation range
Clay (Putty)e0.0 - 0.10 - Nearly perfectly inelastic
Billiard Ballse0.92 - 0.98 - Phenolic resin, polished
Gravitational Accel. (Earth)g9.81m/s2Sea level, 45° latitude
Gravitational Accel. (Moon)g1.62m/s2Approx. 1/6 Earth gravity
Gravitational Accel. (Mars)g3.72m/s2Approx. 0.38 Earth gravity
Gravitational Accel. (Jupiter)g24.79m/s2Gas giant surface equiv.
Linear Momentump - kg⋅m/sp = mv
Kinetic EnergyKE - JKE = ½mv2
Semi-implicit Euler Order - 1 - Symplectic, energy-stable for oscillatory systems
Spatial Hash Cell Size - 2×rmaxpxOptimal when cell ≥ largest diameter
Velocity Damping Ranged0.90 - 1.00 - 1.00 = no damping
Time Step (Fixed)Δt0.016s~60 FPS equivalent
Overlap Correction Factor - 0.4 - 0.8 - Percentage of penetration resolved per frame
Max Bodies (Smooth) - 200 - 500 - Depends on device GPU/CPU

Frequently Asked Questions

When e < 1, the collision is inelastic. A fraction of kinetic energy converts to heat, sound, and deformation energy. The impulse formula scales the relative separation velocity by e, so the post-collision speeds are lower than required for full energy return. Only when e &equals; 1 (perfectly elastic) is kinetic energy fully conserved. Momentum is always conserved regardless of e.
Brute-force detection checks every pair, giving O(n2) comparisons. The spatial hash divides the canvas into cells sized to the largest body diameter. Each body is inserted into the cell(s) it overlaps. Collision checks only occur between bodies sharing the same cell. For uniformly distributed bodies this reduces to approximately O(n) checks, allowing hundreds of bodies at 60 FPS.
Discrete time stepping means a body moves v Δt pixels per frame. If this displacement exceeds the body radius, it can skip past a wall boundary between frames. Mitigation strategies include reducing Δt, capping maximum velocity, or using continuous collision detection (CCD) with swept-sphere tests. This simulator clamps velocity to prevent the most extreme cases but does not implement full CCD.
Standard (explicit) Euler updates position using the old velocity, then updates velocity. This introduces energy drift: oscillatory systems gain energy over time and eventually explode. Semi-implicit Euler updates velocity first, then uses the new velocity for position. This symplectic property preserves the phase-space area, making it energy-stable for gravitational simulations. It is first-order accurate but vastly more stable than explicit Euler at equivalent time steps.
Mass is computed as proportional to the area of the circle: m &equals; ρ π r2, where ρ is a configurable density constant. This means a body with twice the radius has four times the mass, producing realistic-looking collisions where large bodies are harder to deflect. You can override density to create heavy-small or light-large bodies.
No. All bodies are treated as non-rotating circles with point-mass inertia. Collisions only produce linear impulse along the contact normal. Tangential friction, torque, and angular velocity are not modeled. For applications requiring spin (billiards English, gear meshing), a full rigid-body engine with moment-of-inertia tensors would be needed.