For the 2D space simulator that I am writing (please note, it is not at all homework), I require formulas that will give me the location and velocity of a spaceship, relative to the parent celestial body, at a specific time in the future.
There is only one planetary mass that provides a gravitational attraction for the spaceship, and the spaceship's mass is negligible. From the initial $\vec{r}$ and $\vec{v}$ relative to the planet, I already know how to compute many things, such as:
- standard gravitation parameter $\mu = G M$
- eccentricity $e$
- specific angular momentum $h$
- semi-major axis $a = \frac{h^2}{\mu(1 - e^2)}$ (is this even correct?)
- longitude of periapsis $\varpi$
- eccentric anomoly $E$ from true anomaly $\theta$ (an angle the describes an offset from $\varpi$), and vice versa
So using all these values, or possible more (or less), what formulas can I use to compute the position and velocity in $t$ seconds? I have already tried using the following formulas to compute the position in the future:
- mean anomaly $M(E) = E - e sin E$
- mean anomaly at periapsis $M_0 = M(E = \theta = 0)$
- mean anomaly at a certain time $M(t) = M_0 + t \sqrt{\frac{\mu}{a^3}}$
However, those formulas don't work for certain orbits (such as hyperbolic orbits, where $a < 0$). Also, I may have just programmed the formulas incorrectly, but using mean anomaly, my simulator does not correctly determine position in the future.
So, I have already tried several approaches to computing position and velocity in the future, and they didn't work. What are the correct formulas?
Thanks!
No comments:
Post a Comment