Momentum

What is momentum?

Just like energy, momentum is defined in terms of the mass and velocity of an object, with one significant difference: momentum is a vector quantity – not scalar like energy.

It is calculated as the product of the mass of the moving body multiplied by the velocity (this time treating the velocity as a vector). It is usually referred to as “p” in formulas. So we have:

\vec{p}=m\vec{v}

To get the total momentum of a system we need to use vector addition to sum up the momentum vectors of each part of the system. As with energy, the momentum of individual parts of the system will change, but the total momentum of the system will remain constant. In the diagram below you can see that the momentum of each ball changes, but the total momentum remains unchanged.

To calculate the momentum of a ball we can just add a function to our class to return the momentum as a new vector value like this:

momentum() {
  return p5.Vector.mult(this.vel, this.mass)
}

Now we modify our simulation to display the momentum of each ball as well as the total momentum of the system. At the moment none of these values are changing because we are not handling the collisions, but once we do we expect to see the momentum of each ball to change after a collision, but the total momentum should remain the same.