# Semi-major axis from cartesian co-ordinates

## Main Question or Discussion Point

Can anyone suggest how to calculate the semi major axis of a body in an elliptical orbit when all I've got is x,y,z,vx,vy and vz?

I'm guessing I need to calculate the eccentricity too. I really suck at conversions like this. :(

Related Astronomy and Astrophysics News on Phys.org
ideasrule
Homework Helper
Keplerian orbits are all two-dimensional, so you don't need to worry about z or vz; they can be defined as 0.

Take a look at http://en.wikipedia.org/wiki/Orbit#Analysis_of_orbital_motion, especially the equation at the very end. Provided you know the mass & position of the body being orbited, the semi-major axis (a) can easily be calculated.

D H
Staff Emeritus
Can anyone suggest how to calculate the semi major axis of a body in an elliptical orbit when all I've got is x,y,z,vx,vy and vz?

I'm guessing I need to calculate the eccentricity too. I really suck at conversions like this. :(
You better have at least one other thing. You need to know the body's gravitational constant, G*M, which are often combined as a single parameter μ.

Hint: How is the specific angular momentum related to the semi-major axis?
Hint: You need to calculate the eccentricity.

Keplerian orbits are all two-dimensional, so you don't need to worry about z or vz; they can be defined as 0.
No, they can't. He is given non-zero values. Ignoring them *will* yield the wrong answer.

ideasrule
Homework Helper
Yes, if you're actually given a set of positions and velocities in all dimensions, you can't ignore one of them. Ignoring z and Vz only works if you get to arbitrarily define your coordinate system, in which case you can set both to 0.

You better have at least one other thing. You need to know the body's gravitational constant, G*M, which are often combined as a single parameter μ.

Hint: How is the specific angular momentum related to the semi-major axis?
Hint: You need to calculate the eccentricity.

No, they can't. He is given non-zero values. Ignoring them *will* yield the wrong answer.
aha, so I can use:

$$\textbf{h}=\textbf{r}\times\textbf{v}$$

to find the specific angular momentum and then

$$a\left(1-e\right)=\frac{h^{2}}{GM}$$

But then how can I separate the eccentricity and semi-major axis?

D H
Staff Emeritus
But then how can I separate the eccentricity and semi-major axis?
Simple: Compute the eccentricity vector and take its magnitude. So what's this eccentricity vector thing?

$$\vec e = \frac{\vec v \times \vec h}{GM} - \frac{\vec r}{||\vec r||}$$

Simple: Compute the eccentricity vector and take its magnitude. So what's this eccentricity vector thing?

$$\vec e = \frac{\vec v \times \vec h}{GM} - \frac{\vec r}{||\vec r||}$$
Ok, I've done that now.

One thing though, I also found the following equations which I found http://microsat.sm.bmstu.ru/e-library/Ballistics/kepler.pdf [Broken]:

$$a=\frac{GMr}{2GM-rv^{2}}$$

and

$$e=\sqrt{1-\frac{h^{2}}{GMa}}$$

I've tested both sets of equations and I get the same numbers for the eccentricity, which is good. However, I'm getting different results for the semi major axis. :(

Last edited by a moderator:
D H
Staff Emeritus
$$a=\frac{GMr}{2GM-rv^{2}}$$
http://photos-d.ak.fbcdn.net/hphotos-ak-snc1/hs017.snc1/4224_95107990559_95107705559_3010885_4034015_s.jpg [Broken]

The vis-viva equation, doh!

$$v^2=GM\left(\frac 2 r - \frac 1 a\right)$$

I was thinking to much of your problem in term of converting cartesian position and velocity to orbital elements (six of them). The specific angular momentum and the eccentricity vector are the keys to unlocking that puzzle. However, all you wanted was the semi-major axis. The vis-viva is the key to answering that particular problem.

I've tested both sets of equations and I get the same numbers for the eccentricity, which is good. However, I'm getting different results for the semi major axis. :(
That's because you have the relation between angular momentum wrong, here:
$$a\left(1-e\right)=\frac{h^{2}}{GM}$$
That should be

$$a(1-e^2) = \frac {h^2}{GM}$$

Last edited by a moderator:
DH, you are an absolute star and a lifesaver!! Thanks so much for the help!!