Gravity Simulator 2D: Calculating Trajectories

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 2K views
Pink panther
Messages
1
Reaction score
0
I want to create a simple 2d Gravity simulator where I have a large body i.e. A circle which could be a planet or the sun. I then want to simulate small comets or asteroids traveling past it, crashing into or being pulled into orbit. I know the gravitational force formula but that seems the simple part. What I want to know is how to calculate the trajectories for objects flying past. I guess speed and angle of approach determine whether a smaller object will crash, go past or go into orbit around the larger body. Any explanations or sources would be appreciated.
 
Physics news on Phys.org
Hello Pinky, :welcome:

Your gravitational force formula is most likely something like ##\vec F = - {GMm\over |\vec r|^2} \, \hat r##. The equation of motion is ##\vec F = m\vec a## where ##\vec a = {d\vec v \over dt}## and ##\vec v = {d\vec r \over dt}##.
If you want it in x, y coordinates you will need a coordinate transformation at some suitable moment.
That's really all there's to it !

Things become more complicated if you want to can no longer ignore the influence of the smaller m on the big M. Maybe that comes later; for now I interpret your large/small as a permit to ignore the motion of the large body.​