# How to calculate linar velocity of planet orbit?

I try to simulate a solar system with planets (with random mass) placed randomly around a sun with a mass $X \times \text{solar mass}$.

The simulation is going well when I use real data (sun,earth,moon for instance), but now I'd like to simulate randomly generated system.

My problem is that I didn't succeed in calculating linear velocity of planet.

On internet, I only found formulas to calculate linear velocity when we know the angular velocity, this mean knowing the time the planet make to do a revolution , which I don't want to determine.

I want, knowing only the distance and the two mass (and direction of velocity vector), be able to calculate the linear velocity vector.

I don't really have more information to provide, if you need something, just ask for it.

## migrated from scicomp.stackexchange.comJan 30 '13 at 13:38

This question came from our site for scientists using computers to solve scientific problems.

• The distance, the two masses, and the direction of the velocity vector simply do not determine the magnitude of the velocity. You need something more. – Joe Jan 30 '13 at 13:46
• And what do i need ? – eephyne Jan 30 '13 at 14:02
• Either one of: the angular velocity, the angular momentum, the period (time it takes to make one revolution), orbit eccentricity, distance of shortest approach, and there are many more possible parameters. – Joe Jan 30 '13 at 14:14
• What @Joe said, you need one more piece of information. Also, I'm not quite clear on whether you're asking for a way to get your initial conditions (which is a good question), or whether you're asking for equations to update the velocity at each timestep (in which case you may be off to a shaky start - calculating the velocity from your parameters - +1 more of course - is likely to introduce a systematic error). If I had to pick one extra parameter to assign, I think I'd go with eccentricity (given your desire to make things random, it seems the most naturally randomizable). – Kyle Oman Jan 30 '13 at 14:25
• Also curious as to what kind of integration method you're using. This (en.wikipedia.org/wiki/Leapfrog_integration) is usually my weapon of choice for a quick and dirty simulation as it's pretty good at conserving energy for ~periodic orbits. There are, of course, many other good choices, and the one you pick may affect how you want to calculate the velocity. – Kyle Oman Jan 30 '13 at 14:27

## 2 Answers

As mentioned in the comments, you need one more piece of information to determine the magnitude of the velocity.

You said that you might use the eccentricity, so in that case you can use the formula given here and deduce a quadratic equation on the velocity which yields:

$$v= \sqrt{\frac{G M}{r \sin(\alpha)} (1 \pm \epsilon)},$$

where $G$ is the gravitational constant, $r$ is the distance between the two masses, $M$ is the bigger mass (I assumed here that one mass is much bigger than the other), $\alpha$ is the angle between the velocity vector and the radius, and $\epsilon$ is the eccentricity.

Note that since we had a quadratic equation, you still have two options for the velocity, both consistent with the given eccentricity.

• This is perfect ! thanks a lot. Just to be sure , the α is always PI/2 or -PI/2 , no ? – eephyne Jan 30 '13 at 16:37
• No! $\alpha$ can be anything from 0 to $\pi / 2$. Remember this is not restricted to a circular orbit. I did assume $\alpha$ is positive, otherwise just take its absolute value. – Joe Jan 30 '13 at 16:43

I assume that you want to have stable orbits. Then you know that the centrifugal force equals the gravitational force:

GmM/r² = mv²/r

with G = Newtons constant, r the distance and m the mass of the planet and M the mass of the central object. Since you know the distance and the mass of the central object (the mass of the planet cancels out) you can calculate v. v² =GM/r

• This is only for a perfectly circular orbit, and the OP did not pose such a restriction. – Joe Jan 30 '13 at 14:23
• Sorry, this was not clear for me – Noldig Jan 30 '13 at 14:26
• that's one of the formulas I found but when i apply it , I got extremly high result (eg: for earth fixed vector is 29.783 and generated with your formula : 941690.7474866967) – eephyne Jan 30 '13 at 14:28
• @eephyne - note that one of the parameters I mentioned in my comment is the orbit eccentricity. When you use this formula you're restricting yourself to a circular orbit, meaning you take the eccentricity to be zero. – Joe Jan 30 '13 at 14:42
• @eephyne: for an elliptical orbit see en.wikipedia.org/wiki/Elliptic_orbit and en.wikipedia.org/wiki/Orbit_equation. – John Rennie Jan 30 '13 at 16:18