kepler said:
Hi Tony,
I've tested the routine that you gave here, and the results aren't correct for the Earth-Moon system by some misterious cause. I tried with AU as unit of distance, and with meters. It gives wrong results both ways; but just to be sure, here are the value of the vectores for the moon at 1/1/2000, 12h00, in
Actually, it wants kilometers and km/s. I inputted the following values for the moon's earth-relative position on Jan 1, 2002 12:00:00:
X = -226545.429682968: y = 286349.964075857: z = 22167.1721237376
xd = -0.83215986700533: yd = -0.67880264763759: zd = 0.073458217887696
and it returned the following:
sma= 390528.587811472
ecc= 6.42167877853417E-02
perapsis = 51.5661090865652
inclination = 5.26463171719322
ascending node 87.1361489019904
Which seems in the right ball park anyway.
The above input was generated by JPL Horizons system for the Moon for Jan 1, 2002 at 12:00. Asking for elements instead of vectors gives the following (angles in radians):
JDCT Epoch Julian Date, Coordinate Time
EC Eccentricity, e
QR Periapsis distance, q (km)
IN Inclination w.r.t xy-plane, i (degrees)
OM Longitude of Ascending Node, OMEGA, (degrees)
W Argument of Perifocus, w (degrees)
Tp Time of periapsis (Julian day number)
N Mean motion, n (degrees/sec)
MA Mean anomaly, M (degrees)
TA True anomaly, nu (degrees)
A Semi-major axis, a (km)
AD Apoapsis distance (km)
PR Orbital period (sec)
2452276.000000000 = A.D. 2002-Jan-01 12:00:00.0000 (CT)
EC= 5.152445531449781E-02 QR= 3.653672052491503E+05 IN= 5.264631717193200E+00
OM= 8.713614890199040E+01 W = 5.396714814738498E+01 Tp= 2452276.865982342046
N = 1.522267598936786E-04 MA= 3.486102607231271E+02 TA= 3.473660261921209E+02
A = 3.852152090756327E+05 AD= 4.050632129021150E+05 PR= 2.364893007323014E+06
I purposely left out my code for mean anomoly since my routine gets it wrong. I'm anxious to see if Jeneb's code works for this. I tried his code and got a wrong value for inclination, but I haven't checked my work for typos yet. Something to do after work I guess...
Also, I'm not sure how much difference it makes, but I believe the small differences between Horizons output and my code's output is because my code treats the object orbiting Earth as a massless test particle. I'll try this later, but I believe entering the Mass of Earth + Mass of Moon for the variable mass will give me a more correct answer for SMA and Ecc. Not sure about the others.