Two Balls Colliding in One-Dimension

This is a demo I created to experiment with physics and collisions between two objects. Use the slider and number box below to change the mass or speed of each circle. Click on "Go" to watch them collide.

Special thanks to Isaac Newton for making this demo possible

Some Notes About This Demo

An elastic collision is a collision where the total momentum of the objects colliding are preserved. In other words, none of the energy involved in the collision is converted to heat, friction or other forms of energy. While the speed of each object may change, the total amount of kinetic energy of the objects remain the same before and after the collision. All we are concerned with is how the two colliding objects effect each other's movement.

In order to calculate the collision, we want to keep track of how heavy each object is and how fast they are traveling. For example, if a large truck crashes into a small car, the car will go flying while the impact may barely effect the truck's course of travel. On the other hand if a car is driving quickly and hits a truck, that truck will move much more than if the car was driving slowly.

To accurately emulate such collisions, I had to use two physics equations:

m1u1 + m2u2 = m1v1 + m2v2

and

½m1u12 + ½m2u22 = ½m1v12 + ½m2v22

where:

m1 = mass of object 1
u1 = initial velocity of object 1
v1 = final velocity of object 1
m2 = mass of object 2
u2 = initial velocity of object 2
v2 = final velocity of object 2


What we're interested in is finding the final velocities (i.e. the values of v1 and v2). This gives us two equations and two unknowns, so with a little algebra we get:

v1 = u1(m1 - m2) + 2m2u2       
m1 + m2


This entry in wikipedia has more explanations on all the physics and math involved in computing the collision.