I have my position and velocity vectors, and also the mass and position of the sun. I need to convert my vectors to the Keplerian Orbit elements, but I can't get a definite number when I do. The orbit isn't changing, yet the 'constant' values I'm calculating are.

I've been reading this and others such as this.

I first calculate the angular momentum with $\vec{h} = \vec{r} \times \vec{v}$. This value changes as the planet goes around the orbit.

Then I calculate the eccentricity with $$\vec{e} = \frac{(v^2-\mu /r)\vec{r}-(\vec{r} \cdot \vec{v})\vec{v}}{\mu}$$

But this changes between 0.9 and 1.1 as the planet orbits, which as far as I'm aware, shouldn't happen. What is going wrong? Perhaps I'm missing something, but surely the calculations I have say that the orbit changes from an ellipse to a hyperbola, and back again.

Any help would be appreciated, thanks.

  • $\begingroup$ The specific angular momentum vector, the eccentricity vector, and the specific energy (you didn't mention that last one) are all constants of motion. They do not change over the orbit. What are you doing to get the $\vec{r}$ and $\vec{v}$ values around the orbit? $\endgroup$ – Mark Adler Jul 9 '15 at 14:51
  • $\begingroup$ Are you using a barycentric frame of reference? $\endgroup$ – fibonatic Jul 9 '15 at 14:52
  • $\begingroup$ To get the the r and v vectors, I'm just taking them from the object (using rigidbody.position, and rigibody.velocity). My velocity vector is changing as I'm applying force, in the direction vector x (which directs towards the sun). Does that affect why this is changing? And I'm not sure about the barycentric frame of reference, I'm just using a grid coordinate system (If that's what you mean) $\endgroup$ – Jacob Morris Jul 9 '15 at 15:05
  • $\begingroup$ Barycentric frame of reference means that the origin of the coordinate system lies at the center of mass, therefore momentum of all bodies is zero, such that the center of mass does not move away from the origin of the coordinate system. $\endgroup$ – fibonatic Jul 9 '15 at 15:21
  • 2
    $\begingroup$ "My velocity vector is changing as I'm applying force, in the direction vector x (which directs towards the sun)" x is always towards the Sun? Is your force proportional to the inverse square of the distance from the Sun? It sounds like you're implementing the physics yourself, so you need to make sure that it's correct. $\endgroup$ – Mark Adler Jul 10 '15 at 1:31

I suspect your problem is that you are using the altitude of the object, and not the distance from it's center. Make sure you are using the distance to the center of the object, and I believe your problem will resolve itself.

  • $\begingroup$ Yes. Another mistake that can cause this is not using consistent units for r, v, and mu. $\endgroup$ – Matt Jessick Feb 4 '16 at 0:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.