int swi_moshplan2 (double J, int iplm, double *pobj) { int i, j, k, m, k1, ip, np, nt; signed char FAR *p; double FAR *pl, *pb, *pr; double su, cu, sv, cv, T; double t, sl, sb, sr; struct plantbl *plan = planets[iplm]; T = (J - J2000) / TIMESCALE; /* Calculate sin( i*MM ), etc. for needed multiple angles. */ for (i = 0; i < 9; i++) { if ((j = plan->max_harmonic[i]) > 0) { sr = (mods3600 (freqs[i] * T) + phases[i]) * STR; sscc (i, sr, j); } } /* Point to start of table of arguments. */ p = plan->arg_tbl; /* Point to tabulated cosine and sine amplitudes. */ pl = plan->lon_tbl; pb = plan->lat_tbl; pr = plan->rad_tbl; sl = 0.0; sb = 0.0; sr = 0.0; for (;;) { /* argument of sine and cosine */ /* Number of periodic arguments. */ np = *p++; if (np < 0) break; if (np == 0) { /* It is a polynomial term. */ nt = *p++; /* Longitude polynomial. */ cu = *pl++; for (ip = 0; ip < nt; ip++) { cu = cu * T + *pl++; } sl += mods3600 (cu); /* Latitude polynomial. */ cu = *pb++; for (ip = 0; ip < nt; ip++) { cu = cu * T + *pb++; } sb += cu; /* Radius polynomial. */ cu = *pr++; for (ip = 0; ip < nt; ip++) { cu = cu * T + *pr++; } sr += cu; continue; } k1 = 0; cv = 0.0; sv = 0.0; for (ip = 0; ip < np; ip++) { /* What harmonic. */ j = *p++; /* Which planet. */ m = *p++ - 1; if (j) { k = j; if (j < 0) k = -k; k -= 1; su = ss[m][k]; /* sin(k*angle) */ if (j < 0) su = -su; cu = cc[m][k]; if (k1 == 0) { /* set first angle */ sv = su; cv = cu; k1 = 1; } else { /* combine angles */ t = su * cv + cu * sv; cv = cu * cv - su * sv; sv = t; } } } /* Highest power of T. */ nt = *p++; /* Longitude. */ cu = *pl++; su = *pl++; for (ip = 0; ip < nt; ip++) { cu = cu * T + *pl++; su = su * T + *pl++; } sl += cu * cv + su * sv; /* Latitiude. */ cu = *pb++; su = *pb++; for (ip = 0; ip < nt; ip++) { cu = cu * T + *pb++; su = su * T + *pb++; } sb += cu * cv + su * sv; /* Radius. */ cu = *pr++; su = *pr++; for (ip = 0; ip < nt; ip++) { cu = cu * T + *pr++; su = su * T + *pr++; } sr += cu * cv + su * sv; } pobj[0] = STR * sl; pobj[1] = STR * sb; pobj[2] = STR * plan->distance * sr + plan->distance; return OK; }
static void moon1() { double a; /* Mean longitudes of planets (Laskar, Bretagnon) */ Ve = mods3600( 210664136.4335482 * T + 655127.283046 ); Ve += (((((((( -9.36e-023 * T - 1.95e-20 ) * T + 6.097e-18 ) * T + 4.43201e-15 ) * T + 2.509418e-13 ) * T - 3.0622898e-10 ) * T - 2.26602516e-9 ) * T - 1.4244812531e-5 ) * T + 0.005871373088 ) * T2; Ea = mods3600( 129597742.26669231 * T + 361679.214649 ); Ea += (((((((( -1.16e-22 * T + 2.976e-19 ) * T + 2.8460e-17 ) * T - 1.08402e-14 ) * T - 1.226182e-12 ) * T + 1.7228268e-10 ) * T + 1.515912254e-7 ) * T + 8.863982531e-6 ) * T - 2.0199859001e-2 ) * T2; Ma = mods3600( 68905077.59284 * T + 1279559.78866 ); Ma += (-1.043e-5*T + 9.38012e-3)*T2; Ju = mods3600( 10925660.428608 * T + 123665.342120 ); Ju += (1.543273e-5*T - 3.06037836351e-1)*T2; Sa = mods3600( 4399609.65932 * T + 180278.89694 ); Sa += (( 4.475946e-8*T - 6.874806E-5 ) * T + 7.56161437443E-1)*T2; sscc( 0, STR*D, 6 ); sscc( 1, STR*M, 4 ); sscc( 2, STR*MP, 4 ); sscc( 3, STR*NF, 4 ); moonpol[0] = 0.0; moonpol[1] = 0.0; moonpol[2] = 0.0; /* terms in T^2, scale 1.0 = 10^-5" */ chewm( LRT2, NLRT2, 4, 2, moonpol ); chewm( BT2, NBT2, 4, 4, moonpol ); f = 18 * Ve - 16 * Ea; g = STR*(f - MP ); /* 18V - 16E - l */ cg = cos(g); sg = sin(g); l = 6.367278 * cg + 12.747036 * sg; /* t^0 */ l1 = 23123.70 * cg - 10570.02 * sg; /* t^1 */ l2 = z[24] * cg + z[25] * sg; /* t^2 */ l3 = z[26] * cg + z[27] * sg; /* t^3 */ l4 = z[28] * cg + z[29] * sg; /* t^4 */ moonpol[2] += 5.01 * cg + 2.72 * sg; g = STR * (10.*Ve - 3.*Ea - MP); cg = cos(g); sg = sin(g); l += -0.253102 * cg + 0.503359 * sg; l1 += 1258.46 * cg + 707.29 * sg; l2 += z[30] * cg + z[31] * sg; l3 += z[32] * cg + z[33] * sg; l4 += z[34] * cg + z[35] * sg; g = STR*(8.*Ve - 13.*Ea); cg = cos(g); sg = sin(g); l += -0.187231 * cg - 0.127481 * sg; l1 += -319.87 * cg - 18.34 * sg; l2 += z[36] * cg + z[37] * sg; l3 += z[38] * cg + z[39] * sg; l4 += z[40] * cg + z[41] * sg; a = 4.0*Ea - 8.0*Ma + 3.0*Ju; g = STR * a; cg = cos(g); sg = sin(g); l += -0.866287 * cg + 0.248192 * sg; l1 += 41.87 * cg + 1053.97 * sg; l2 += z[42] * cg + z[43] * sg; g = STR*(a - MP); cg = cos(g); sg = sin(g); l += -0.165009 * cg + 0.044176 * sg; l1 += 4.67 * cg + 201.55 * sg; g = STR*f; /* 18V - 16E */ cg = cos(g); sg = sin(g); l += 0.330401 * cg + 0.661362 * sg; l1 += 1202.67 * cg - 555.59 * sg; l2 += z[44] * cg + z[45] * sg; l3 += z[46] * cg + z[47] * sg; g = STR*(f - 2.0*MP ); /* 18V - 16E - 2l */ cg = cos(g); sg = sin(g); l += 0.352185 * cg + 0.705041 * sg; l1 += 1283.59 * cg - 586.43 * sg; l2 += z[48] * cg + z[49] * sg; l3 += z[50] * cg + z[51] * sg; g = STR * (2.0*Ju - 5.0*Sa); cg = cos(g); sg = sin(g); l += -0.034700 * cg + 0.160041 * sg; l2 += z[52] * cg + z[53] * sg; g = STR * (LP - NF); cg = cos(g); sg = sin(g); l += 0.000116 * cg + 7.063040 * sg; l1 += 298.8 * sg; l2 += z[54] * cg + z[55] * sg; /* T^3 terms */ sg = sin( STR * M ); l3 += z[56] * sg; l4 += z[57] * sg; g = STR * (2.0*D - M); sg = sin(g); cg = cos(g); l3 += z[58] * sg; l4 += z[59] * sg; moonpol[2] += -0.2655 * cg * T; g = g - STR * MP; sg = sin(g); l3 += z[60] * sg; l4 += z[61] * sg; g = STR * (M - MP); l3 += z[62] * sin( g ); moonpol[2] += -0.1568 * cos( g ) * T; g = STR * (M + MP); l3 += z[63] * sin( g ); moonpol[2] += 0.1309 * cos( g ) * T; g = STR * 2.0 * (D - M); sg = sin(g); l3 += z[64] * sg; l4 += z[65] * sg; g = STR * 2.0 * M; sg = sin(g); l3 += z[66] * sg; l4 += z[67] * sg; g = STR * (2.0*D - MP); sg = sin(g); l3 += z[68] * sg; g = STR * (2.0*(D - M) - MP); sg = sin(g); l3 += z[69] * sg; g = STR * (2.0*(D + M) - MP); sg = sin(g); cg = cos(g); l3 += z[70] * sg; moonpol[2] += 0.5568 * cg * T; l2 += moonpol[0]; g = STR*(2.0*D - M - MP); moonpol[2] += -0.1910 * cos( g ) * T; moonpol[1] *= T; moonpol[2] *= T; /* terms in T */ moonpol[0] = 0.0; chewm( BT, NBT, 4, 4, moonpol ); chewm( LRT, NLRT, 4, 1, moonpol ); g = STR*(f - MP - NF - 2355767.6); /* 18V - 16E - l - F */ moonpol[1] += -1127. * sin(g); g = STR*(f - MP + NF - 235353.6); /* 18V - 16E - l + F */ moonpol[1] += -1123. * sin(g); g = STR*(Ea + D + 51987.6); moonpol[1] += 1303. * sin(g); g = STR*LP; moonpol[1] += 342. * sin(g); g = STR*(2.*Ve - 3.*Ea); cg = cos(g); sg = sin(g); l += -0.343550 * cg - 0.000276 * sg; l1 += 105.90 * cg + 336.53 * sg; g = STR*(f - 2.*D); /* 18V - 16E - 2D */ cg = cos(g); sg = sin(g); l += 0.074668 * cg + 0.149501 * sg; l1 += 271.77 * cg - 124.20 * sg; g = STR*(f - 2.*D - MP); cg = cos(g); sg = sin(g); l += 0.073444 * cg + 0.147094 * sg; l1 += 265.24 * cg - 121.16 * sg; g = STR*(f + 2.*D - MP); cg = cos(g); sg = sin(g); l += 0.072844 * cg + 0.145829 * sg; l1 += 265.18 * cg - 121.29 * sg; g = STR*(f + 2.*(D - MP)); cg = cos(g); sg = sin(g); l += 0.070201 * cg + 0.140542 * sg; l1 += 255.36 * cg - 116.79 * sg; g = STR*(Ea + D - NF); cg = cos(g); sg = sin(g); l += 0.288209 * cg - 0.025901 * sg; l1 += -63.51 * cg - 240.14 * sg; g = STR*(2.*Ea - 3.*Ju + 2.*D - MP); cg = cos(g); sg = sin(g); l += 0.077865 * cg + 0.438460 * sg; l1 += 210.57 * cg + 124.84 * sg; g = STR*(Ea - 2.*Ma); cg = cos(g); sg = sin(g); l += -0.216579 * cg + 0.241702 * sg; l1 += 197.67 * cg + 125.23 * sg; g = STR*(a + MP); cg = cos(g); sg = sin(g); l += -0.165009 * cg + 0.044176 * sg; l1 += 4.67 * cg + 201.55 * sg; g = STR*(a + 2.*D - MP); cg = cos(g); sg = sin(g); l += -0.133533 * cg + 0.041116 * sg; l1 += 6.95 * cg + 187.07 * sg; g = STR*(a - 2.*D + MP); cg = cos(g); sg = sin(g); l += -0.133430 * cg + 0.041079 * sg; l1 += 6.28 * cg + 169.08 * sg; g = STR*(3.*Ve - 4.*Ea); cg = cos(g); sg = sin(g); l += -0.175074 * cg + 0.003035 * sg; l1 += 49.17 * cg + 150.57 * sg; g = STR*(2.*(Ea + D - MP) - 3.*Ju + 213534.); l1 += 158.4 * sin(g); l1 += moonpol[0]; a = 0.1 * T; /* set amplitude scale of 1.0 = 10^-4 arcsec */ moonpol[1] *= a; moonpol[2] *= a; }
static int dargs (double J, struct plantbl *plan) { double T2, w; if (J == Jlast) return 0; T = (J - JD2000) / 36525.0; T2 = T * T; /* Mean anomaly of sun = l' (J. Laskar) */ w = mods3600 (129596581.038354 * T + 1287104.76154); w += (((((((( 1.62e-20 * T - 1.0390e-17) * T - 3.83508e-15) * T + 4.237343e-13) * T + 8.8555011e-11) * T - 4.77258489e-8) * T - 1.1297037031e-5) * T + 1.4732069041e-4) * T - 0.552891801772) * T2; sscc (10, STR * w, plan->max_harmonic[10]); /* Mean distance of moon from its ascending node = F */ w = mods3600 ((1739527263.0983 - 2.079419901760e-01) * T + 335779.55755); w = w + ((-9.646018347184e-06 * T2 /* F, t^4 */ - 1.138215912580e-03) * T /* F, t^3 */ - 1.312045233711e+01) * T; /* F, t^2 */ sscc (11, STR * w, plan->max_harmonic[11]); /* Mean anomaly of moon = l */ w = mods3600 ((1717915923.4728 - 2.035946368532e-01) * T + 485868.28096); w = w + ((-3.421689790404e-04 * T2 /* l, t^4 */ + 4.768357585780e-02) * T /* l, t^3 */ + 3.146734198839e+01) * T; /* l, t^2 */ sscc (9, STR * w, plan->max_harmonic[9]); /* Mean elongation of moon = D */ w = mods3600 ((1602961601.4603 + 3.962893294503e-01) * T + 1072260.73512); w = w + ((-2.905334122698e-04 * T2 /* D, t^4 */ - 5.834100476561e-03) * T /* D, t^3 */ - 6.847070905410e+00) * T; /* D, t^2 */ sscc (12, STR * w, plan->max_harmonic[12]); /* Mean longitude of moon, re mean ecliptic and equinox of date */ w = mods3600 ((1732564372.83264 - 6.784914260953e-01) * T + 785939.95571); w = w + ((-8.466472828815e-05 * T2 /* L, t^4 */ + 5.722859298199e-03) * T /* L, t^3 */ - 5.663161722088e+00) * T; /* L, t^2 */ sscc (13, STR * w, plan->max_harmonic[13]); /* Mean longitudes of planets (Laskar, Bretagnon) */ /* Venus. */ w = mods3600 (210664136.4335482 * T + 655127.283046); w += (((((((( -9.36e-023 * T - 1.95e-20) * T + 6.097e-18) * T + 4.43201e-15) * T + 2.509418e-13) * T - 3.0622898e-10) * T - 2.26602516e-9) * T - 1.4244812531e-5) * T + 0.005871373088) * T2; sscc (1, STR * w, plan->max_harmonic[1]); /* Earth. */ w = mods3600 (129597742.26669231 * T + 361679.214649); w += ((((((((-1.16e-22 * T + 2.976e-19) * T + 2.8460e-17) * T - 1.08402e-14) * T - 1.226182e-12) * T + 1.7228268e-10) * T + 1.515912254e-7) * T + 8.863982531e-6) * T - 2.0199859001e-2) * T2; sscc (2, STR * w, plan->max_harmonic[2]); /* Mars. */ w = mods3600 (68905077.59284 * T + 1279559.78866); w += (-1.043e-5 * T + 9.38012e-3) * T2; sscc (3, STR * w, plan->max_harmonic[3]); /* Jupiter. */ w = mods3600 (10925660.428608 * T + 123665.342120); w += (1.543273e-5 * T - 3.06037836351e-1) * T2; sscc (4, STR * w, plan->max_harmonic[4]); /* Saturn. */ w = mods3600 (4399609.65932 * T + 180278.89694); w += ((4.475946e-8 * T - 6.874806E-5) * T + 7.56161437443E-1) * T2; sscc (5, STR * w, plan->max_harmonic[5]); return 0; }
int nutlo(double J) { double f, g, T, T2, T10; double MM, MS, FF, DD, OM; double cu, su, cv, sv, sw; double C, D; int i, j, k, k1, m; short *p; if( jdnut == J ) return(0); jdnut = J; /* Julian centuries from 2000 January 1.5, * barycentric dynamical time */ T = (J-2451545.0)/36525.0; T2 = T * T; T10 = T / 10.0; /* Fundamental arguments in the FK5 reference system. */ /* longitude of the mean ascending node of the lunar orbit * on the ecliptic, measured from the mean equinox of date */ OM = (mod3600 (-6962890.539 * T + 450160.280) + (0.008 * T + 7.455) * T2) * STR; /* mean longitude of the Sun minus the * mean longitude of the Sun's perigee */ MS = (mod3600 (129596581.224 * T + 1287099.804) - (0.012 * T + 0.577) * T2) * STR; /* mean longitude of the Moon minus the * mean longitude of the Moon's perigee */ MM = (mod3600 (1717915922.633 * T + 485866.733) + (0.064 * T + 31.310) * T2) * STR; /* mean longitude of the Moon minus the * mean longitude of the Moon's node */ FF = (mod3600 (1739527263.137 * T + 335778.877) + (0.011 * T - 13.257) * T2) * STR; /* mean elongation of the Moon from the Sun. */ DD = (mod3600 (1602961601.328 * T + 1072261.307) + (0.019 * T - 6.891) * T2) * STR; /* Calculate sin( i*MM ), etc. for needed multiple angles */ sscc( 0, MM, 3 ); sscc( 1, MS, 2 ); sscc( 2, FF, 4 ); sscc( 3, DD, 4 ); sscc( 4, OM, 2 ); C = 0.0; D = 0.0; p = &nt[0]; /* point to start of table */ for( i=0; i<105; i++ ) { /* argument of sine and cosine */ k1 = 0; cv = 0.0; sv = 0.0; for( m=0; m<5; m++ ) { j = *p++; if( j ) { k = j; if( j < 0 ) k = -k; su = ss[m][k-1]; /* sin(k*angle) */ if( j < 0 ) su = -su; cu = cc[m][k-1]; if( k1 == 0 ) { /* set first angle */ sv = su; cv = cu; k1 = 1; } else { /* combine angles */ sw = su*cv + cu*sv; cv = cu*cv - su*sv; sv = sw; } } } /* longitude coefficient */ f = *p++; if( (k = *p++) != 0 ) f += T10 * k; /* obliquity coefficient */ g = *p++; if( (k = *p++) != 0 ) g += T10 * k; /* accumulate the terms */ C += f * sv; D += g * cv; } /* first terms, not in table: */ C += (-1742.*T10 - 171996.)*ss[4][0]; /* sin(OM) */ D += ( 89.*T10 + 92025.)*cc[4][0]; /* cos(OM) */ /* printf( "nutation: in longitude %.3f\", in obliquity %.3f\"\n", C, D ); */ /* Save answers, expressed in radians */ nutl = 0.0001 * STR * C; nuto = 0.0001 * STR * D; return(0); }