112 LOCAL void moonOrbitals(
double t_cy, OrbTerms *orb);
113 LOCAL void moonLongDist(
const OrbTerms *orb,
double *long_udeg,
double *dist_m);
114 LOCAL double moonLatitude(
const OrbTerms *orb);
115 LOCAL double riseSetApprox(
double risesetGuess_d,
130 LOCAL const double au_km = 1.49597871464e8;
162 double a1_rad, a2_rad, a3_rad;
163 double l_udeg, b_udeg;
165 double dl_udeg, db_udeg;
177 moonOrbitals(t_cy, &orbt);
180 moonLongDist(&orbt, &l_udeg, &r_m);
181 b_udeg = moonLatitude(&orbt);
184 a1_rad =
degToRad(119.75 + 131.849 * t_cy);
185 a2_rad =
degToRad(53.09 + 479264.29 * t_cy);
186 a3_rad =
degToRad(313.45 + 481266.484 * t_cy);
189 dl_udeg = 3958.0 * sin(a1_rad) + 1962.0 * sin(orbt.lp_rad - orbt.f_rad)
190 + 318.0 * sin(a2_rad);
191 db_udeg = -2235.0 * sin(orbt.lp_rad) + 382.0 * sin(a3_rad)
192 + 175.0 * sin(a1_rad - orbt.f_rad)
193 + 175.0 * sin(a1_rad + orbt.f_rad)
194 + 127.0 * sin(orbt.lp_rad - orbt.mp_rad)
195 - 115.0 * sin(orbt.lp_rad + orbt.mp_rad);
200 beta_rad =
degToRad((b_udeg + db_udeg) / 1e6);
201 mDelta_km = 385000.56 + r_m / 1000.0;
205 *dist_au = mDelta_km / au_km;
208 lamda_rad = lamdap_rad + nut->
dPsi_rad;
378 for (i = 0; i < 3; i++) {
379 estimate_d = riseSetApprox(estimate_d, getMoonrise, deltas,&st, &topo1);
380 if (estimate_d == 0.0) {
400 LOCAL void moonOrbitals(
double t_cy, OrbTerms *orb)
412 temp_deg = 218.3164477
413 + t_cy * (481267.88123421
415 + t_cy * (1.0 / 538841.0
416 + t_cy * (-1.0 / 65194000.0))));
420 temp_deg = 297.8501921
421 + t_cy * (445267.1114034
423 + t_cy * (1.0 / 545868.0
424 + t_cy * (-1.0 / 113065000.0))));
428 temp_deg = 357.5291092
429 + t_cy * (35999.0502909
431 + t_cy * (1.0 / 24490000.0)));
435 temp_deg = 134.9633964
436 + t_cy * (477198.8675055
438 + t_cy * (1.0 / 69699.0
439 + t_cy * (-1.0 / 14712000.0))));
443 temp_deg = 93.2720950
444 + t_cy * (483202.0175233
446 + t_cy * (-1.0 / 3526000.0
447 + t_cy * (1.0 / 863310000.0))));
451 orb->e = 1.0 - 0.002516 * t_cy - 0.0000074 * t_cy * t_cy;
456 LOCAL void moonLongDist(
const OrbTerms *orb,
double *long_udeg,
double *dist_m)
466 static const LonDistTerms lonD[] = {
467 { 0, 0, 1, 0, 6288774,-20905355 },
468 { 2, 0,-1, 0, 1274027,-3699111 },
469 { 2, 0, 0, 0, 658314,-2955968 },
470 { 0, 0, 2, 0, 213618,-569925 },
471 { 0, 1, 0, 0,-185116, 48888 },
472 { 0, 0, 0, 2,-114332,-3149 },
473 { 2, 0,-2, 0, 58793, 246158 },
474 { 2,-1,-1, 0, 57066,-152138 },
475 { 2, 0, 1, 0, 53322,-170733 },
476 { 2,-1, 0, 0, 45758,-204586 },
477 { 0, 1,-1, 0,-40923,-129620 },
478 { 1, 0, 0, 0,-34720, 108743 },
479 { 0, 1, 1, 0,-30383, 104755 },
480 { 2, 0, 0,-2, 15327, 10321 },
481 { 0, 0, 1, 2,-12528, 0 },
482 { 0, 0, 1,-2, 10980, 79661 },
483 { 4, 0,-1, 0, 10675,-34782 },
484 { 0, 0, 3, 0, 10034,-23210 },
485 { 4, 0,-2, 0, 8548,-21636 },
486 { 2, 1,-1, 0,-7888, 24208 },
487 { 2, 1, 0, 0,-6766, 30824 },
488 { 1, 0,-1, 0,-5163,-8379 },
489 { 1, 1, 0, 0, 4987,-16675 },
490 { 2,-1, 1, 0, 4036,-12831 },
491 { 2, 0, 2, 0, 3994,-10445 },
492 { 4, 0, 0, 0, 3861,-11650 },
493 { 2, 0,-3, 0, 3665, 14403 },
494 { 0, 1,-2, 0,-2689,-7003 },
495 { 2, 0,-1, 2,-2602, 0 },
496 { 2,-1,-2, 0, 2390, 10056 },
497 { 1, 0, 1, 0,-2348, 6322 },
498 { 2,-2, 0, 0, 2236,-9884 },
499 { 0, 1, 2, 0,-2120, 5751 },
500 { 0, 2, 0, 0,-2069, 0 },
501 { 2,-2,-1, 0, 2048,-4950 },
502 { 2, 0, 1,-2,-1773, 4130 },
503 { 2, 0, 0, 2,-1595, 0 },
504 { 4,-1,-1, 0, 1215,-3958 },
505 { 0, 0, 2, 2,-1110, 0 },
506 { 3, 0,-1, 0,-892, 3258 },
507 { 2, 1, 1, 0,-810, 2616 },
508 { 4,-1,-2, 0, 759,-1897 },
509 { 0, 2,-1, 0,-713,-2117 },
510 { 2, 2,-1, 0,-700, 2354 },
511 { 2, 1,-2, 0, 691, 0 },
512 { 2,-1, 0,-2, 596, 0 },
513 { 4, 0, 1, 0, 549,-1423 },
514 { 0, 0, 4, 0, 537,-1117 },
515 { 4,-1, 0, 0, 520,-1571 },
516 { 1, 0,-2, 0,-487,-1739 },
517 { 2, 1, 0,-2,-399, 0 },
518 { 0, 0, 2,-2,-381,-4421 },
519 { 1, 1, 1, 0, 351, 0 },
520 { 3, 0,-2, 0,-340, 0 },
521 { 4, 0,-3, 0, 330, 0 },
522 { 2,-1, 2, 0, 327, 0 },
523 { 0, 2, 1, 0,-323, 1165 },
524 { 1, 1,-1, 0, 299, 0 },
525 { 2, 0, 3, 0, 294, 0 },
526 { 2, 0,-1,-2, 0, 8752 },
528 static const int lonDistSize =
ARRAY_SIZE(lonD);
533 double a_rad, sinA, cosA;
538 for (i = lonDistSize - 1; i >= 0; i--) {
541 if (lonD[i].cm != 0) {
545 if (abs(lonD[i].cm) == 2) {
551 a_rad = lonD[i].cd * orb->d_rad + lonD[i].cm * orb->m_rad
552 + lonD[i].cmp * orb->mp_rad + lonD[i].cf * orb->f_rad;
553 sincos(a_rad, &sinA, &cosA);
555 *long_udeg += li * sinA;
556 *dist_m += ri * cosA;
562 LOCAL double moonLatitude(
const OrbTerms *orb)
570 static const LatTerms lat[] = {
571 { 0, 0, 0, 1, 5128122 },
572 { 0, 0, 1, 1, 280602 },
573 { 0, 0, 1,-1, 277693 },
574 { 2, 0, 0,-1, 173237 },
575 { 2, 0,-1, 1, 55413 },
576 { 2, 0,-1,-1, 46271 },
577 { 2, 0, 0, 1, 32573 },
578 { 0, 0, 2, 1, 17198 },
579 { 2, 0, 1,-1, 9266 },
580 { 0, 0, 2,-1, 8822 },
581 { 2,-1, 0,-1, 8216 },
582 { 2, 0,-2,-1, 4324 },
583 { 2, 0, 1, 1, 4200 },
584 { 2, 1, 0,-1,-3359 },
585 { 2,-1,-1, 1, 2463 },
586 { 2,-1, 0, 1, 2211 },
587 { 2,-1,-1,-1, 2065 },
588 { 0, 1,-1,-1,-1870 },
589 { 4, 0,-1,-1, 1828 },
590 { 0, 1, 0, 1,-1794 },
591 { 0, 0, 0, 3,-1749 },
592 { 0, 1,-1, 1,-1565 },
593 { 1, 0, 0, 1,-1491 },
594 { 0, 1, 1, 1,-1475 },
595 { 0, 1, 1,-1,-1410 },
596 { 0, 1, 0,-1,-1344 },
597 { 1, 0, 0,-1,-1335 },
598 { 0, 0, 3, 1, 1107 },
599 { 4, 0, 0,-1, 1021 },
639 for (i = latSize - 1; i >= 0; i--) {
641 if (lat[i].cm != 0) {
644 if (abs(lat[i].cm) == 2) {
648 lat_udeg += bi * sin(lat[i].cd * orb->d_rad
649 + lat[i].cm * orb->m_rad
650 + lat[i].cmp * orb->mp_rad
651 + lat[i].cf * orb->f_rad);
659 LOCAL double riseSetApprox(
double risesetGuess_d,
694 double riseSetApprox_d;
708 if (fabs(cosHa2) > 1.0) {
709 riseSetApprox_d = 0.0;
712 ha2_rad = -acos(cosHa2);
714 ha2_rad = acos(cosHa2);
721 if ((ha1_rad - ha2_rad) >
PI) { risesetGuess_d += 1.0; }
722 if ((ha1_rad - ha2_rad) < -
PI) { risesetGuess_d -= 1.0; }
723 riseSetApprox_d = risesetGuess_d - (ha1_rad - ha2_rad) /
TWOPI * 1.03;
725 return riseSetApprox_d;