Falling under Gravity

Falling under Gravity

Falling under gravity is one of the most common things you will find particles doing. Bits from explosions, firework sparks, rain and snow all follow a similar pattern. These are all 'dumb' particles, in that they simply get pushed around by the laws of physics and cannot act on themselves.

So, these particles will need some properties. They need a position in space, and a velocity.
Their position is (x, y, z)
Their velocity is (xv, yv, zv)

Right, so assuming that the Y dimension is negative downwards then we can take gravity to be an acceleration vector downwards.
Their acceleration is (0, -1, 0).

As was said in the previous article, the acceleration affects the velocity, and the velocity affects the position. So on each loop of the program, the velocity is added to the position and the acceleration is added to the velocity:

  for each particle
    erase particle
    position = position + velocity
    velocity = velocity + acceleration
    draw particle
  end of particle loop
end of main loop

And there you have it. Particle motion is really very simple. Every one of those particles will travel in a nice little parabola.