Collision Lab

Set two balls in motion in one or two dimensions, choose how bouncy the impact is, and watch velocity, momentum and kinetic energy before and after they collide.

Set up the collision

Dimension
Scenarios
Ball 1
Ball 2
Playback speed
t = 0.00 s
While paused, drag a ball to reposition it — the run restarts from the new setup.

Right now

Ball 1Ball 2Σ
Velocity m/s
Momentum kg·m/s
Kinetic energy J

Before and after the collision

Press play — the moment the balls collide, this comparison fills in by itself.

The formulas in use

Momentum and kinetic energy
p = m·v, KE = ½·m·|v|²
Impact along the line of centers
j = −(1 + e) · (v_rel · n̂) ÷ (1/m₁ + 1/m₂)
v₁′ = v₁ − (j/m₁)·n̂, v₂′ = v₂ + (j/m₂)·n̂
e = −(v_rel′ · n̂) ÷ (v_rel · n̂), v_rel = v₂ − v₁
Head-on elastic special case (e = 1)
v₁′ = ((m₁ − m₂)·v₁ + 2·m₂·v₂) ÷ (m₁ + m₂)
Head-on perfectly inelastic special case (e = 0)
v′ = (m₁·v₁ + m₂·v₂) ÷ (m₁ + m₂)
Between impacts
x ← x + v·Δt
No forces act between impacts, so positions advance exactly, each impact is resolved at its precise moment of contact within a frame — fast balls cannot slip through each other — and the walls reflect a ball without changing its speed.

The whole simulation runs in this browser — nothing you set up is uploaded.

FAQ

What does the coefficient of restitution actually control?

It is the ratio of how fast the balls separate to how fast they approached, measured along the line joining their centers. At e = 1 the bounce returns the full approach speed and kinetic energy is conserved; at e = 0 the balls stop separating altogether — in a head-on hit they move on together as one lump. Everything in between loses part of the energy: a basketball rebounds at roughly e ≈ 0.6, a tennis ball on concrete at about 0.75.

Why is momentum conserved even when kinetic energy is not?

During the impact the two balls push on each other with equal and opposite forces, so whatever momentum one loses, the other gains — the total cannot change, whatever the value of e. Kinetic energy has no such protection: in a soft impact part of it turns into deformation, heat and sound. The before-and-after table shows exactly this — the momentum row keeps its value while the energy row drops.

Why don’t the balls stick together in a 2D perfectly inelastic hit?

e = 0 removes the separation speed along the line of centers — the direction in which the balls actually press on each other. In a head-on hit that is the whole motion, so they travel on together. In a glancing hit each ball also has sideways motion along the contact surface, and smooth, frictionless balls have no grip to cancel it, so their paths part even though the bounce itself is gone. Making them truly stick would need friction or interlocking, which this model deliberately leaves out.

How close is this to a real collision?

The conservation laws are exact — they are what crash investigators and particle physicists rely on. What is idealized here is everything else: real objects deform over milliseconds rather than instantaneously, spin when struck off-center, rub against each other and roll to a stop. Treat the numbers as the textbook limit a clean experiment approaches, not as a prediction for a specific real object.

Simulating 1D and 2D Collisions in the Animated Arena

Collision Lab provides an interactive environment to study the mechanics of elastic and inelastic impacts. By configuring the physical properties of two balls, you can observe their motion in real time and analyze the resulting changes in velocity, momentum, and kinetic energy.

The simulation operates in two dimensional modes:

  • 1D track: Restricts the motion of the balls to a single horizontal axis, ideal for analyzing head-on impacts.
  • 2D plane: Allows the balls to move and collide in a two-dimensional space, enabling the study of glancing impacts.

The simulation displays an Animated arena showing the two balls moving and colliding, with their velocity arrows and the center of mass marked. While the simulation is paused, you can drag a ball directly in the arena to reposition it, which restarts the run from the new setup.


Configuring the Collision Parameters

To set up a simulation, you can adjust the properties of both balls and the elasticity of the collision:

  • Coefficient of restitution e: A slider ranging from perfectly inelastic (minimum, where e = 0) to elastic (maximum, where e = 1).
  • Mass: A positive numerical value up to 1000 kg for each ball.
  • Position x and Position y: Numerical coordinates defining the starting positions (with Position y active only in the 2D plane mode).
  • Velocity x and Velocity y: Numerical velocity components restricted within the range of ±50 m/s.
  • Simulation controls: Play, Pause, Step (advance a small, fixed time slice) and Reset, together with a Playback speed switch offering Normal and Slow.

Preset Scenarios

For quick configuration, the tool includes several preset Scenarios:

  • Equal masses, head-on: Demonstrates a classic velocity exchange between identical masses.
  • Heavy hits light: Shows how a high-mass ball transfers momentum to a lighter target.
  • Rear-end: Simulates one ball overtaking another from behind along the same line of motion.
  • Perfectly inelastic: Sets e = 0 so the balls do not separate along their line of centers after impact.
  • Glancing 2D hit: Sets up an off-center collision in the two-dimensional plane.

Real-Time Data and Before-and-After Comparisons

As the simulation runs, the tool provides continuous feedback through status messages and data tables. The status bar displays Set the masses and velocities, then press play. when waiting for input, Simulation running. during playback, and Paused at t = ‹t› s. when stopped.

Live Data Table

The Right now table displays real-time values for both balls as they move across the arena:

  • Velocity
  • Momentum
  • Kinetic energy
  • Total momentum
  • Total kinetic energy

Collision Comparison Table

The moment the balls hit, the tool automatically populates the Before and after the collision table. This table freezes the state of the system immediately before and after the impact, displaying the following metrics:

  • Collision ‹n›, at t = ‹t› s (tracking the collision count and exact timestamp)
  • Columns for Before, After, and Change
  • Rows for Velocity, Momentum, and Kinetic energy for each ball
  • A summary reading: Kinetic energy lost in the impact: ‹value› J (‹percent› of the total before it)

Mathematical Formulas in Use

The simulation engine calculates the motion and collision resolutions using the following plain Unicode mathematical formulas:

Momentum and Kinetic Energy

The fundamental properties of each ball are calculated using:

  • p = m·v
  • KE = ½·m·|v|²

Impact Along the Line of Centers

When a collision occurs, the tool calculates the impulse vector along the unit vector n̂ that joins the centers of the two balls. Let the relative velocity vector be v_rel = v₂ − v₁. The impulse magnitude j is calculated as:

  • j = −(1 + e) · (v_rel · n̂) ÷ (1/m₁ + 1/m₂)

The post-collision velocities (v₁′ and v₂′) are then resolved by applying the impulse:

  • v₁′ = v₁ − (j/m₁)·n̂
  • v₂′ = v₂ + (j/m₂)·n̂

The coefficient of restitution e is defined by the ratio of relative separation velocity to relative approach velocity along the line of centers:

  • e = −(v_rel′ · n̂) ÷ (v_rel · n̂)

Special Cases

  • Head-on elastic special case (e = 1): v₁′ = ((m₁ − m₂)·v₁ + 2·m₂·v₂) ÷ (m₁ + m₂)
  • Head-on perfectly inelastic special case (e = 0): shared velocity v′ = (m₁·v₁ + m₂·v₂) ÷ (m₁ + m₂)

Motion Between Impacts

Between collisions, no external forces act on the balls. The positions are updated exactly using:

  • x ← x + v·Δt

Because no forces like friction or gravity are present, this calculation is exact and does not rely on numerical approximations.


Simulation Rules, Boundaries, and Error Handling

To maintain physical consistency within this idealized teaching model, the simulation enforces several boundaries and rules:

  • Boundary Collisions: The walls of the arena act as perfectly elastic barriers, reflecting a ball without changing its speed.
  • Impact Resolution: Each impact is resolved at its precise moment of contact within a frame, ensuring fast-moving balls cannot slip through each other or overlap.
  • Idealized Physics Assumptions: The simulation assumes smooth discs, zero friction, zero gravity, zero spin, and instantaneous impacts.

Input Validation and Error Messages

If you enter invalid parameters, the tool will display one of the following error messages:

  • If an input is not a valid number: Ball ‹n›, ‹field›: “‹token›” is not a number. (where ‹field› can be mass, position x, position y, velocity x, or velocity y).
  • If mass is zero or negative: Ball ‹n›: the mass must be greater than zero..
  • If mass exceeds the limit: Ball ‹n›: masses above 1000 kg are outside this demo’s range..
  • If velocity components exceed limits: Ball ‹n›: keep each velocity component within ±50 m/s..
  • If a ball is placed outside the boundaries: Ball ‹n› starts outside the arena — move it back inside the walls..
  • If the balls overlap at startup: The two balls overlap at the start — move them apart before running..

Privacy and Processing

The entire simulation runs locally in your web browser, meaning nothing you set up is uploaded to an external server.


Frequently Asked Questions

What does the coefficient of restitution actually control?

It is the ratio of how fast the balls separate to how fast they approached, measured along the line joining their centers. At e = 1 the bounce returns the full approach speed and kinetic energy is conserved; at e = 0 the balls stop separating altogether — in a head-on hit they move on together as one lump. Everything in between loses part of the energy: a basketball rebounds at roughly e ≈ 0.6, a tennis ball on concrete at about 0.75.

Why is momentum conserved even when kinetic energy is not?

During the impact the two balls push on each other with equal and opposite forces, so whatever momentum one loses, the other gains — the total cannot change, whatever the value of e. Kinetic energy has no such protection: in a soft impact part of it turns into deformation, heat and sound. The before-and-after table shows exactly this — the momentum row keeps its value while the energy row drops.

Why don’t the balls stick together in a 2D perfectly inelastic hit?

e = 0 removes the separation speed along the line of centers — the direction in which the balls actually press on each other. In a head-on hit that is the whole motion, so they travel on together. In a glancing hit each ball also has sideways motion along the contact surface, and smooth, frictionless balls have no grip to cancel it, so their paths part even though the bounce itself is gone. Making them truly stick would need friction or interlocking, which this model deliberately leaves out.

How close is this to a real collision?

The conservation laws are exact — they are what crash investigators and particle physicists rely on. What is idealized here is everything else: real objects deform over milliseconds rather than instantaneously, spin when struck off-center, rub against each other and roll to a stop. Treat the numbers as the textbook limit a clean experiment approaches, not as a prediction for a specific real object.