# Calculation of Eccentricity of orbit from velocity and radius

For a school project I am making a gravitational computer model. As I want to Milankovitch cycles, I need to calculate the eccentricity of an orbit after the model has completed its simulation.

I have thought about calculating the eccentricity using the aphelion and parohelion height, but these are not available as it is a simulation and as it therefore stores the data for one point on the ellipse.

The data I have after the model has completed:
X,Y,Z coordinates of points that it has saved
X,Y,Z velocities of points that it has saved

I have been able to calculate the semi-major axis using the vis-viva equation. I have tried to get the value using the vis-viva equation but I got stuck as I think I need at least the Aphelion or Parohelion to calculate the eccentricity.

My question: Does anyone know how to calculate the eccentricity at any given point in the orbit using the velocity and coordinates (without simulating all points around it)?

If not, does anyone maybe have a better idea/suggestion that I can try to gain the eccentricity values?

• Hi, it's not clear what your inputs are - how do you even verify your model is generating a stable orbit if you don't know how to identify apogee and perigee? But, assuming your data show a stable pattern (the x-y-z position and velocity data follow some reasonably repeatable path), why not fit your data to a curve (ellipse) and calculate the eccentricity from that? – Carl Witthoft Jan 3 '19 at 16:32

If you have the relative position $$\mathbf{r}$$ and velocity $$\mathbf{v}$$ at the same point in time, compute the eccentricity vector:

$$\mathbf{e} = \frac{\mathbf{v} \times \mathbf{h}}{\mu} - \frac{\mathbf{r}}{\|\mathbf{r}\|}$$

Where $$\mathbf{h} = \mathbf{r} \times \mathbf{v}$$ is the specific relative angular momentum and $$\mu = GM$$ is the standard gravitational parameter.

The eccentricity is then given by the norm of the eccentricity vector $$\left\| \mathbf{e} \right\|$$.

One uses the so called eccentricity vector, also called (up to a factor) Laplace-Runge-Lenz vector.

Given the position $$\vec{r} = \begin{bmatrix}x\\ y\\ z\end{bmatrix}$$ of the object at given time $$t$$ and its velocity $$\vec{v} = \begin{bmatrix}u\\ v\\ w\end{bmatrix}$$ both with respect to an inertial coordinate system cantered at the origin of the gravitational field, the eccentricity of the orbit (Keplerian case) can be calculated by first computing the eccentricity vector:

Step 1: Calculate the angular momentum $$\vec{L} = \vec{r} \times \vec{v}$$ Step 2: Calculate the eccentricity vector $$\vec{e} = \frac{1}{\mu}\, \big(\,\vec{v} \times \vec{L}\,\big) - \frac{\vec{r}}{|r|}$$ Step 3: Calculate eccentricity $$e = |\vec{e}| = \sqrt{\vec{e} \circ \vec{e}\,}$$ where $$\cdot \circ \cdot$$ is the dot product, e.g. $$|r| = \sqrt{\vec{r} \circ \vec{r}\,} = \sqrt{x^2 + y^2 + z^2}$$

• I would like to thank you as well for your answer as it covered the same approach (using the angular momentum). But as I can only give the green price to one saving hand, I have decided to give it to mistertribs. Thank you! – Stijn Jan 5 '19 at 12:41
• @Stijn Thank you, no problem, mistertribs was the first to point in the right direction, so he should get the credit. – Futurologist Jan 6 '19 at 3:44