Elastic Collision Simulator

JJ Ben-Joseph headshot JJ Ben-Joseph

Enter masses and velocities then press Play.
Simulation summary will appear here.

1. Real‑world phenomenon

When two carts on an air track bump into each other and rebound without any loss of kinetic energy, they enact an elastic collision. Such encounters are idealizations—real collisions always dissipate some energy—but they serve as crucial stepping stones for understanding more complex impacts. Pool balls, atomic nuclei, and gas molecules often behave nearly elastically, transferring momentum like perfectly bouncy marbles. The calculator above preserves the original purpose of solving for post‑collision velocities yet transforms the experience into a dynamic experiment. Instead of merely reading numbers, you can watch two blocks slide, collide, and fly apart on a canvas. Energy bars glow in blue and orange to signify how each block’s kinetic energy evolves, while a live caption narrates the action for screen‑reader users. The CSV export captures every time step so you can analyze momentum and energy conservation in your favorite plotting tool.

2. Variables and assumptions

The simulation considers two rigid blocks moving along a frictionless horizontal line. Block 1 has mass m_1 and initial velocity v_1; block 2 has mass m_2 and initial velocity v_2. Positive velocities point to the right. The blocks start well separated so that they approach each other before contact. Because the collision is perfectly elastic, kinetic energy and linear momentum are conserved. We neglect rotational motion, deformation, and external forces such as friction or air drag. Internally, the script converts all inputs to SI units (kilograms, meters, seconds) and validates that masses are positive, velocities finite, and the integration step Δt lies between 0.0005 and 0.05 seconds. If any quantity fails these checks, the simulation refuses to run, preventing nonsensical results. The blocks are drawn as rectangles with equal width for simplicity; their masses are indicated only through the dynamics and energy bars.

3. Governing equations

Before collision, each block travels at constant velocity; their positions evolve according to x_i(t)=x_{i0}+v_it. When the blocks’ edges coincide, we apply conservation of momentum m_1v_1+m_2v_2=m_1v_1'+m_2v_2' and kinetic energy 12m_1v_12+12m_2v_22=12m_1v_1'2+12m_2v_2'2 to determine the post‑collision velocities v_1' and v_2'. Solving these simultaneously yields

v_1'=m_1-m_2m_1+m_2v_1+2m_2m_1+m_2v_2

v_2'=2m_1m_1+m_2v_1+m_2-m_1m_1+m_2v_2

After the collision, each block continues at its new constant velocity. Kinetic energies KE_i=12m_iv_i2 feed the energy bars. Their sum remains equal to the initial total, within numerical error.

4. Numerical scheme

The simulator uses an explicit time‑stepping algorithm. Positions are updated each frame via x_i+=v_iΔt until the right edge of block 1 meets the left edge of block 2. Because the velocities remain constant between collisions, this simple integrator is exact aside from the discrete time step determining when contact occurs. To minimize overlap error, the code detects when the blocks would cross during a step and solves for the precise collision time using linear interpolation. The velocities are then replaced with the analytic solutions above, and integration resumes. The time step is user‑adjustable; smaller steps yield smoother motion but require more computation. The canvas animation runs at the browser’s refresh rate, decoupled from the physics time step so that you can slow or accelerate the simulation without jitter. A running total of kinetic energy before and after collision allows us to compute the fractional energy drift, which should remain near zero for elastic impacts. If drift exceeds 0.5% the caption issues a warning, alerting you that the step is too coarse.

5. Worked example

Consider two carts on a frictionless track. Cart 1 has mass 1 kg and moves rightward at 2 m/s. Cart 2 has mass 2 kg and moves leftward at 1 m/s. With Δt=0.01 s, entering these values and pressing Play shows the carts approaching from opposite sides. They meet at 0.67 s, after which cart 1 rebounds leftward at −1 m/s while cart 2 continues rightward at 2 m/s. The energy bars initially display 2 J for cart 1 and 1 J for cart 2. After collision they swap: cart 1 holds 0.5 J and cart 2 holds 2.5 J, yet the total remains 3 J. Exporting the CSV confirms these numbers: the rows around the collision time show energy conservation and instantaneous velocity changes. Such data mirror the momentum transfers measured in introductory physics labs.

6. Comparison table

The table compares the baseline example above with two variations. Values are extracted from simulation data.

Scenariom₁ (kg)m₂ (kg)v₁ (m/s)v₂ (m/s)v₁′ (m/s)v₂′ (m/s)
Baseline122-1-12
Equal masses112-1-12
Heavy target1520-1.330.67

When the masses are equal, the blocks simply exchange velocities. A much heavier second block causes the lighter one to rebound with reduced speed while the heavy block drifts forward. These scenarios highlight how momentum sharing depends on mass ratio.

7. How to read the animation

The canvas shows a gray track with a blue block representing m_1 and an orange block for m_2. A thin trail follows each block, marking previous positions. The energy bar beneath uses blue stripes for block 1 and orange stripes for block 2; their lengths scale with instantaneous kinetic energy. Because the bars rely on patterns and labeled segments, distinguishing colors is unnecessary. The caption below the canvas reports the current time, velocities, and energy drift so assistive technology receives the same information. Keyboard users can focus the canvas and press the space bar to toggle play and pause.

8. Limitations

Real collisions rarely maintain perfect elasticity. Surface roughness, internal vibrations, and deformation siphon energy into heat and sound. The model treats blocks as points along a line, ignoring rotational effects or off‑center impacts that would introduce spin. Numerical detection of the collision assumes constant velocities within each time step; extremely large steps could allow blocks to pass through each other without registering impact, though the allowed Δt range prevents this. Finally, only a single collision is modeled; multiple bounces or wall impacts would require additional logic.

9. Suggested extensions

Future versions could include coefficient‑of‑restitution input to explore partially elastic collisions, or chains of multiple blocks to demonstrate momentum transfer like a Newton’s cradle. Adding momentum and energy graphs would provide deeper diagnostics of numerical error. A two‑dimensional variant with vector velocities could illustrate glancing collisions, while coupling the blocks with springs would link this simulator to our Mass–Spring Oscillation Simulator. For related concepts, see the Inelastic Collision Simulator and experiment with projectile impacts using the Projectile Motion Simulator.

10. References

Embed this calculator

Copy and paste the HTML below to add the Elastic Collision Simulator with Energy Tracking to your website.