float m = JulianDay / 12; //month, approximation
float d = 367 * 2000 - 7 * ( 2000 + (m / 12 + 9) / 12 ) / 4 + 275 * m/9 + JulianDay - 730530;
d = d + (TimeOfDay / 3600.0f) / 24.0;
float N = (125.1228 - 0.0529538083 * d) / 180 * PI;
float i = 5.1454;
float w = (318.0634 + 0.1643573223 * d) / 180 * PI;
float e = 0.054900; //eccentricity
float M = (115.3654 + 13.0649929509 * d) / 180.0f * PI ; //mean anomaly
float E = M + e * sin(M) * ( 1.0 + e * cos(M) );
E = E - ( E - e * sin(E) - M ) / ( 1 - e * cos(E) );
float xv = ( cos(E) - e );
float yv = ( sqrt(1.0 - e*e) * sin(E) );
float v = atan2( yv, xv );
float xh = ( cos(N) * cos(v+w) - sin(N) * sin(v+w) * cos(i) );
float yh = ( sin(N) * cos(v+w) + cos(N) * sin(v+w) * cos(i) );
float zh = ( sin(v+w) * sin(i) );
MoonPhi = atan2( yh, xh ); //longitude
MoonTheta = atan2( zh, sqrt(xh*xh+yh*yh) ); //latitude
Simple Moon Position Calculation
Does anyone know of any very simple moon position calculator? currently I'm using the algorithm from Computing Planetary Positions which I found on vterrain.org. The code I got is: I'm not sure whether this is very correct, the moon does seem to move nicely and continuously but I don't know if the position in the sky is correct.
Check:
http://www.stargazing.net/kepler/moon.html
http://njsas.org/projects/tidal_forces/altaz/pausch/ppcomp.html
http://www.stargazing.net/kepler/moon.html
http://njsas.org/projects/tidal_forces/altaz/pausch/ppcomp.html
your value for i (inclination) is also in degrees and needs the 180 PI added
float i = 5.1454 / 180 * PI;
haha, I used a moon rotation function similar to the one you used. It moved elliptically which was neat, but I ended up opting for a simple circle rotation to save those few extra processing steps.
Thread was dormant for 12 years. Please don't necro. Locking thread.
-- Tom Sloper -- sloperama.com
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement