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.
The simulation considers two rigid blocks moving along a frictionless horizontal line. Block 1 has mass and initial velocity ; block 2 has mass and initial velocity . 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 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.
Before collision, each block travels at constant velocity; their positions evolve according to . When the blocks’ edges coincide, we apply conservation of momentum and kinetic energy to determine the post‑collision velocities and . Solving these simultaneously yields
After the collision, each block continues at its new constant velocity. Kinetic energies feed the energy bars. Their sum remains equal to the initial total, within numerical error.
The simulator uses an explicit time‑stepping algorithm. Positions are updated each frame via 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.
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 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.
The table compares the baseline example above with two variations. Values are extracted from simulation data.
Scenario | m₁ (kg) | m₂ (kg) | v₁ (m/s) | v₂ (m/s) | v₁′ (m/s) | v₂′ (m/s) |
---|---|---|---|---|---|---|
Baseline | 1 | 2 | 2 | -1 | -1 | 2 |
Equal masses | 1 | 1 | 2 | -1 | -1 | 2 |
Heavy target | 1 | 5 | 2 | 0 | -1.33 | 0.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.
The canvas shows a gray track with a blue block representing and an orange block for . 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.
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 range prevents this. Finally, only a single collision is modeled; multiple bounces or wall impacts would require additional logic.
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.