Gravity simulator 2d

Tags:
1. Dec 28, 2015

Pink panther

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 travelling 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.

2. Dec 28, 2015

BvU

Hello Pinky,

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.​