- #1

- 158

- 23

I have a body of negligible mass orbiting a body of considerable mass, with that larger body fixed at the origin. I am given the orbital state vector (position and velocity), and need to return the apoapsis of orbit. Other orbital information would be useful, e.g. energy, angular momentum, eccentricity, etc.

For simplicity, the system is assumed to be in a plane... I am not concerned with the third position/vector component.

What I have so far:

Sorry about the formatting, it's in Matlab language. I am far too lazy to do the latex for such a simple question. The above formulae do not return the correct results.

EDIT: Huh... it may work now. ??????

For simplicity, the system is assumed to be in a plane... I am not concerned with the third position/vector component.

What I have so far:

Code:

```
energy = norm(v)^2/2-S/norm(p);
angmom = dot(p,v);
eccen = sqrt(1+(2*energy*angmom^2)/S^2);
semimajor = 1/(2/norm(p)-norm(v)^2/S);
apoapsis = semimajor*(1+norm(eccen));
```

Sorry about the formatting, it's in Matlab language. I am far too lazy to do the latex for such a simple question. The above formulae do not return the correct results.

EDIT: Huh... it may work now. ??????

Last edited: