# Finding the initial velocity vector of an orbiting body

I'm writing a program that simulates Newton's law of universal gravitation by simply calculating the force and applying it on the objects. The simulation works very well, but now I want to simulate real systems using real data. I looked all over for how to find the initial conditions such as the initial velocity and initial position, but I can't find anything.

I'll make it clear by taking the Earth as an example as in the figure below. How do I calculate w (green vector)? If I want to set up the system and simulate it, what would the Earth's initial velocity be so that it orbits the sun at a period of 365 days? And what would its respective position be? I know the orbital speeds of the Earth and the Moon, but they are obviously not the initial velocities of the bodies in the system.

I played around with the values and got something around 30 km/s, but now the Earth's gravity can't pull the moon along the orbit path because it's too fast, even at extremely small time steps. I can give them similar velocities that is enough to drag the moon along, but then the moon's orbit period becomes less than 27 days. By the sounds of it you have made a mistake with the units. In fact, you should not be using SI units at all in your simulation; astronomical values in SI units vary by such huge orders of magnitude that they are often a source of floating point errors that can destroy trajectories.

You should instead use the astronomical system of units. Specifically, express your masses in solar masses, your lengths in the astronomical unit, and time in the mean solar day.

Your value of $G$ will then be the square of the Gaussian gravitational constant, i.e.

$$G=k^2=0.0002959122083\,\mathrm{AU}^3\mathrm{D}^{-2}\mathrm{M}_\odot^{-1}$$

You can get position and velocity data for the planets, their moons, comets, and hundreds of thousands of asteroids, etc, from JPL HORIZONS. You need to connect to their servers via telnet and request the data.

Alternatively, as a starting point, if you know the distance $r$ and mass $m$ of a planet, then its orbital speed should be

$$v = \sqrt{\frac{GM}{r}}$$

where $M=1\,\mathrm{M}_\odot$. If we ignore eccentricity then the direction should be tangential to the orbit (e.g. position it at $(r,0)$ and give it a velocity $(0,v)$).

• Velocity: km/s, distances: km, G: km^3 kg^-1 s^-2= 6.67384*10^-20. I can't seem to find it at JPL. I used this other page (below) from NASA, and it doesn't have the initial velocity; only the orbital velocities. But there should be a way to calculate it using the orbital velocity. nssdc.gsfc.nasa.gov/planetary/factsheet/moonfact.html – Valentin Apr 8 '15 at 11:34
• @Valentin I have updated my answer. – lemon Apr 8 '15 at 15:58
• But again, that's the orbital velocity, which I should get as a result of setting an initial velocity for the orbiting body. I need the initial velocity of the body, which will then change to its orbital velocity as a result of interacting with the sun. I'll see what JPL HORIZONS has. – Valentin Apr 8 '15 at 16:39
• @Valentin The orbital velocity that I give is the initial velocity... – lemon Apr 8 '15 at 17:03
• But what about the moon? I get something like 0.9 km/s. There is no way the moon is that slow. It just can't catch up with the Earth, and the Earth can't pull it strong enough to drag it along. Is there something I got wrong here? – Valentin Apr 8 '15 at 17:44