OOD NBody Simulation Computations

Some extra help

planetarysys

Calculate for each body in the system and every other body:

  • distance square = (x distance between itself and the other body)^2 + (y distance between itself and the other body)^2
  • force = G * its mass * the other’s mass / distance^2
  • forceX = force * (the other’s x position – its x position )/ distance
  • forceY = force * (the other’s y position – its y position )/ distance
  • accelerationX = forceX / its mass
  • accelerationY = forceY / its mass
  • velocityX += deltaT * accelerationX
  • velocityY += deltaT * accelerationY

 

update the new position for the body

  • x position += deltaT * velocityX
  • y position += deltaT * velocityY