- #1
whiterook6
- 4
- 0
.. Using Keplerian Elements
Hi. Disclaimer: this is the first foray into orbits I've ever taken. I only did mechanics in university and haven't really touched it sincew.
I'm busy coding a simulation of a solar system. I've managed to code a routine to calculate the position of a body along an elliptic orbit, using a wikipedia article, but the code breaks down when the eccentricity of the orbit approaches or passes 1.0. Specifically, the true anomaly goes to π and the radius goes to ∞ pretty much immediately when the eccentricity is 1.0; when the eccentricity is >1.0, the true anomaly goes to ∞ too.
So, I'm looking for a little help with an algorithm to calculate points on a parabolic orbit, or on a hyperbolic orbit, using the same parameters like semimajor axis and eccentricity. From what I can see, mean/eccentric/true anomalies don't make sense for parabolic and hyperbolic orbits.
I'll take whatever help you can lend, and I don't need anyone to code me a solution, but I'm specifically looking to calculate the coordinates of a point on the orbit with respect to time.
Thanks for your help!
If you're curious, here's the code:
where solveForEccenticAnomaly solves M=E-e*sin(E).
Hi. Disclaimer: this is the first foray into orbits I've ever taken. I only did mechanics in university and haven't really touched it sincew.
I'm busy coding a simulation of a solar system. I've managed to code a routine to calculate the position of a body along an elliptic orbit, using a wikipedia article, but the code breaks down when the eccentricity of the orbit approaches or passes 1.0. Specifically, the true anomaly goes to π and the radius goes to ∞ pretty much immediately when the eccentricity is 1.0; when the eccentricity is >1.0, the true anomaly goes to ∞ too.
So, I'm looking for a little help with an algorithm to calculate points on a parabolic orbit, or on a hyperbolic orbit, using the same parameters like semimajor axis and eccentricity. From what I can see, mean/eccentric/true anomalies don't make sense for parabolic and hyperbolic orbits.
I'll take whatever help you can lend, and I don't need anyone to code me a solution, but I'm specifically looking to calculate the coordinates of a point on the orbit with respect to time.
Thanks for your help!
If you're curious, here's the code:
Code:
float meanAnomaly=(2.0f*pi*age)/(period)+meanAnomalyAtEpoch,
eccentricAnomaly=solveForEccentricAnomaly(meanAnomaly, eccentricity),
trueAnomaly=2.0f*atan2f(sqrt(1.0f+eccentricity)*sin(eccentricAnomaly/2.0f),
sqrt(1.0f-eccentricity)*cos(eccentricAnomaly/2.0f)),
radius=semiMajorAxis*(1.0f-(eccentricity*eccentricity))/(1+eccentricity*cos(trueAnomaly));