hi just wanted to add somethign which might be usefull,
if u have a moving body with an constant acceleration:
variables: position, velocity, ACCELERATION
One nearly always sees the formular (name: Euler integration):
velocity += ACCELERATION * time;
position += velocity * time;
which is in this case only an approximation which gets worse the bigger your time steps get.
to get the right results use this function
One nearly always sees the formular(name: Verlet integration):
oldVelocity = velocity;
velocity += ACCELERATION * time;
position += ((oldVelocity + velocity) / 2) * time;
which gives u correct results for constant acceleration.
if your acceleration isn’t constant it won’t be correct anymore but still better then the first formular
link on this topic http://codeflow.org/entries/2010/aug/28/integration-by-example-euler-vs-verlet-vs-runge-kutta/