5

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.

Jacob Morris
  • 113
  • 2
  • 8
  • 3
    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? – Mark Adler Jul 09 '15 at 14:51
  • Are you using a barycentric frame of reference? – fibonatic Jul 09 '15 at 14:52
  • 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) – Jacob Morris Jul 09 '15 at 15:05
  • 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. – fibonatic Jul 09 '15 at 15:21
  • I'm using Unity, at the centre of the coordinate system is the sun. – Jacob Morris Jul 09 '15 at 15:55
  • @JacobM Is the sun fixed in place, or can the planet tug on the sun as well, moving it ever so slightly? – fibonatic Jul 09 '15 at 17:37
  • The sun does moves slightly towards the planet yeah. I tried disabling its movement, but it doesn't fix my problem. – Jacob Morris Jul 09 '15 at 17:44
  • 2
    "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. – Mark Adler Jul 10 '15 at 01:31

2 Answers2

1

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.

PearsonArtPhoto
  • 121,132
  • 22
  • 347
  • 614
0

May be a bit late, but I believe if you are using surface velocity, you get such errors. You have to use orbital velocity.