我需要找出月球经度值以找到 Nakshatra 和tithi。
我使用下面的c语言代码来获取月球经度,
//Longitude of Moon
static double moon_long(double d)
{
double N, i, w, a, e, M, E, Et, x, y, r, v, xec, yec, zec, D, F, tmp, tmp1, tmp2, lon;
N = 125.1228-0.0529538083*d;
i = 5.1454;
w = REV(318.0634+0.1643573223*d);
a = 60.2666;
e = 0.054900;
M = REV(115.3654+13.0649929509*d);
Mm = M;
Lm = N+w+M;
//Calculate Eccentricity anamoly
tmp = M*D2R;
E = M+R2D*e*sin(tmp)*(1+e*cos(tmp));
tmp = E*D2R;
Et = E-(E-R2D*e*sin(tmp)-M)/(1-e*cos(tmp));
do {
E = Et;
tmp = E*D2R;
Et = E-(E-R2D*e*sin(tmp)-M)/(1-e*cos(tmp));
} while(E-Et>0.005);
tmp = E*D2R;
x = a*(cos(tmp)-e);
y = a*sqrt(1-e*e)*sin(tmp);
r = sqrt(x*x + y*y);
v = REV(R2D*atan2(y,x));
tmp = D2R*N;
tmp1 = D2R*(v+w);
tmp2 = D2R*i;
xec = r*(cos(tmp)*cos(tmp1)-sin(tmp)*sin(tmp1)*cos(tmp2));
yec = r*(sin(tmp)*cos(tmp1)+cos(tmp)*sin(tmp1)*cos(tmp2));
zec = r*sin(tmp1)*sin(tmp2);
//Do some corrections
D = Lm - Ls;
F = Lm - N;
lon = R2D*atan2(yec,xec);
lon+= -1.274*sin((Mm-2*D)*D2R);
lon+= +0.658*sin((2*D)*D2R);
lon+= -0.186*sin((Ms)*D2R);
lon+= -0.059*sin((2*Mm-2*D)*D2R);
lon+= -0.057*sin((Mm-2*D+Ms)*D2R);
lon+= +0.053*sin((Mm+2*D)*D2R);
lon+= +0.046*sin((2*D-Ms)*D2R);
lon+= +0.041*sin((Mm-Ms)*D2R);
lon+= -0.035*sin((D)*D2R);
lon+= -0.031*sin((Mm+Ms)*D2R);
lon+= -0.015*sin((2*F-2*D)*D2R);
lon+= +0.011*sin((Mm-4*D)*D2R);
return REV(lon);
}
但我得到了错误的值,请你解释一下,如何计算月球经度或我应该使用哪个程序。