57 LOCAL int planetGetEarth(
double t_cy,
70 LOCAL const double lightTime_s = 499.0047863852;
73 LOCAL const double invC_dpau = lightTime_s / 86400.0;
76 LOCAL int currentPlanet = 0;
287 p2V->a[0] = p2V->a[1] = p2V->a[2] = 0.0;
295 ret = planetGetEarth(t_cy, &earthV_au, &earthVelV_aupd);
306 lightTime_d = *dist_au * invC_dpau;
310 np, &helioV_au, NULL);
316 lightTime_d = *dist_au * invC_dpau;
320 np, &helioV_au, NULL);
326 lightTime_d = *dist_au * invC_dpau;
329 p1V.a[0] = geoV_au.a[0] / *dist_au;
330 p1V.a[1] = geoV_au.a[1] / *dist_au;
331 p1V.a[2] = geoV_au.a[2] / *dist_au;
333 aberrV.a[0] = earthVelV_aupd.a[0] * invC_dpau;
334 aberrV.a[1] = earthVelV_aupd.a[1] * invC_dpau;
335 aberrV.a[2] = earthVelV_aupd.a[2] * invC_dpau;
578 static const double GK = 0.017202098950;
581 static const double SINEPS = 0.3977771559319137;
582 static const double COSEPS = 0.9174820620691818;
585 static const int KMAX = 10;
588 double t, da, dl, de, dp, di, dom, dmu, arga, argl, am,
589 ae, dae, ae2, at, r, v, si2, xq, xp, tl, xsw,
590 xcw, xm2, xf, ci2, xms, xmc, xpxq2, x, y, z;
593 static const double amas[] = { 6023600.0,
613 static const double a[][3] = {
614 { 0.3870983098, 0.0, 0.0 },
615 { 0.7233298200, 0.0, 0.0 },
616 { 1.0000010178, 0.0, 0.0 },
617 { 1.5236793419, 3e-10, 0.0 },
618 { 5.2026032092, 19132e-10, -39e-10 },
619 { 9.5549091915, -0.0000213896, 444e-10 },
620 { 19.2184460618, -3716e-10, 979e-10 },
621 { 30.1103868694, -16635e-10, 686e-10 }
624 static const double dlm[][3] = {
625 { 252.25090552, 5381016286.88982, -1.92789 },
626 { 181.97980085, 2106641364.33548, 0.59381 },
627 { 100.46645683, 1295977422.83429, -2.04411 },
628 { 355.43299958, 689050774.93988, 0.94264 },
629 { 34.35151874, 109256603.77991, -30.60378 },
630 { 50.07744430, 43996098.55732, 75.61614 },
631 { 314.05500511, 15424811.93933, -1.75083 },
632 { 304.34866548, 7865503.20744, 0.21103 }
635 static const double e[][3] = {
636 { 0.2056317526, 0.0002040653, -28349e-10 },
637 { 0.0067719164, -0.0004776521, 98127e-10 },
638 { 0.0167086342, -0.0004203654, -0.0000126734 },
639 { 0.0934006477, 0.0009048438, -80641e-10 },
640 { 0.0484979255, 0.0016322542, -0.0000471366 },
641 { 0.0555481426, -0.0034664062, -0.0000643639 },
642 { 0.0463812221, -0.0002729293, 0.0000078913 },
643 { 0.0094557470, 0.0000603263, 0.0 }
646 static const double pi[][3] = {
647 { 77.45611904, 5719.11590, -4.83016 },
648 { 131.56370300, 175.48640, -498.48184 },
649 { 102.93734808, 11612.35290, 53.27577 },
650 { 336.06023395, 15980.45908, -62.32800 },
651 { 14.33120687, 7758.75163, 259.95938 },
652 { 93.05723748, 20395.49439, 190.25952 },
653 { 173.00529106, 3215.56238, -34.09288 },
654 { 48.12027554, 1050.71912, 27.39717 }
657 static const double dinc[][3] = {
658 { 7.00498625, -214.25629, 0.28977 },
659 { 3.39466189, -30.84437, -11.67836 },
660 { 0.0, 469.97289, -3.35053 },
661 { 1.84972648, -293.31722, -8.11830 },
662 { 1.30326698, -71.55890, 11.95297 },
663 { 2.48887878, 91.85195, -17.66225 },
664 { 0.77319689, -60.72723, 1.25759 },
665 { 1.76995259, 8.12333, 0.08135 }
668 static const double omega[][3] = {
669 { 48.33089304, -4515.21727, -31.79892 },
670 { 76.67992019, -10008.48154, -51.32614 },
671 { 174.87317577, -8679.27034, 15.34191 },
672 { 49.55809321, -10620.90088, -230.57416 },
673 { 100.46440702, 6362.03561, 326.52178 },
674 { 113.66550252, -9240.19942, -66.23743 },
675 { 74.00595701, 2669.15033, 145.93964 },
676 { 131.78405702, -221.94322, -0.78728 }
682 static const double kp[][9] = {
683 { 69613, 75645, 88306, 59899, 15746, 71087, 142173, 3086, 0 },
684 { 21863, 32794, 26934, 10931, 26250, 43725, 53867, 28939, 0 },
685 { 16002, 21863, 32004, 10931, 14529, 16368, 15318, 32794, 0 },
686 { 6345, 7818, 15636, 7077, 8184, 14163, 1107, 4872, 0 },
687 { 1760, 1454, 1167, 880, 287, 2640, 19, 2047, 1454 },
688 { 574, 0, 880, 287, 19, 1760, 1167, 306, 574 },
689 { 204, 0, 177, 1265, 4, 385, 200, 208, 204 },
690 { 0, 102, 106, 4, 98, 1367, 487, 204, 0 }
693 static const double ca[][9] = {
694 { 4, -13, 11, -9, -9, -3, -1, 4, 0 },
695 { -156, 59, -42, 6, 19, -20, -10, -12, 0 },
696 { 64, -152, 62, -8, 32, -41, 19, -11, 0 },
697 { 124, 621, -145, 208, 54, -57, 30, 15, 0 },
698 { -23437, -2634, 6601, 6259, -1507,-1821, 2620, -2115, -1489 },
699 { 62911,-119919, 79336,17814,-24241,12068, 8306, -4893, 8902 },
700 { 389061,-262125,-44088, 8387,-22976,-2093, -615, -9720, 6633 },
701 { -412235,-157046,-31430,37817, -9740, -13, -7449, 9644, 0 }
704 static const double sa[][9] = {
705 { -29, -1, 9, 6, -6, 5, 4, 0, 0 },
706 { -48, -125, -26, -37, 18, -13, -20, -2, 0 },
707 { -150, -46, 68, 54, 14, 24, -28, 22, 0 },
708 { -621, 532, -694, -20, 192, -94, 71, -73, 0 },
709 { -14614,-19828, -5869, 1881, -4372, -2255, 782, 930, 913 },
710 { 139737, 0, 24667, 51123, -5102, 7429, -4095, -1976, -9566 },
711 { -138081, 0, 37205,-49039,-41901,-33872,-27037,-12474, 18797 },
712 { 0, 28492,133236, 69654, 52322,-49577,-26430, -3593, 0 }
718 static const double kq[][10] = {
719 { 3086,15746,69613,59899,75645,88306, 12661, 2658, 0, 0 },
720 { 21863,32794,10931, 73, 4387,26934, 1473, 2157, 0, 0 },
721 { 10,16002,21863,10931, 1473,32004, 4387, 73, 0, 0 },
722 { 10, 6345, 7818, 1107,15636, 7077, 8184, 532, 10, 0 },
723 { 19, 1760, 1454, 287, 1167, 880, 574, 2640, 19, 1454 },
724 { 19, 574, 287, 306, 1760, 12, 31, 38, 19, 574 },
725 { 4, 204, 177, 8, 31, 200, 1265, 102, 4, 204 },
726 { 4, 102, 106, 8, 98, 1367, 487, 204, 4, 102 }
729 static const double cl[][10] = {
730 { 21, -95, -157, 41, -5, 42, 23, 30, 0, 0 },
731 { -160, -313, -235, 60, -74, -76, -27, 34, 0, 0 },
732 { -325, -322, -79, 232, -52, 97, 55, -41, 0, 0 },
733 { 2268, -979, 802, 602, -668, -33, 345, 201, -55, 0 },
734 { 7610, -4997,-7689,-5841,-2617, 1115,-748,-607, 6074, 354 },
735 { -18549, 30125,20012, -730, 824, 23,1289,-352, -14767, -2062 },
736 { -135245,-14594, 4197,-4030,-5630,-2898,2540,-306, 2939, 1986 },
737 { 89948, 2103, 8963, 2695, 3682, 1648, 866,-154, -1963, -283 }
740 static const double sl[][10] = {
741 { -342, 136, -23, 62, 66, -52, -33, 17, 0, 0 },
742 { 524, -149, -35, 117, 151, 122, -71, -62, 0, 0 },
743 { -105, -137, 258, 35, -116, -88,-112, -80, 0, 0 },
744 { 854, -205, -936, -240, 140, -341, -97, -232, 536, 0 },
745 { -56980, 8016, 1012, 1448,-3024,-3710, 318, 503, 3767, 577 },
746 { 138606,-13478,-4964, 1441,-1319,-1482, 427, 1236, -9167, -1918 },
747 { 71234,-41116, 5334,-4935,-1848, 66, 434, -1748, 3780, -701 },
748 { -47645, 11647, 2166, 3194, 679, 0,-244, -419, -2531, 48 }
754 REQUIRE((np > 0) && (np <= 8));
758 if ((np < 1) || (np > 8)) {
762 for (k = 0; k < 2; k++) {
763 for (i = 0; i < 3; i++) {
779 jstat = fabs(t) <= 1.0 ? 0 : 1;
785 dl = (3600.0 * dlm[np][0] +
795 di = (3600.0 * dinc[np][0] +
804 dmu = 0.35953620 * t;
805 for (k = 0; k < 8; k++) {
806 arga = kp[np][k] * dmu;
807 argl = kq[np][k] * dmu;
808 da += (ca[np][k] * cos(arga) +
809 sa[np][k] * sin(arga)) * 1e-7;
810 dl += (cl[np][k] * cos(argl) +
811 sl[np][k] * sin(argl)) * 1e-7;
813 arga = kp[np][8] * dmu;
814 da += t * (ca[np][8] * cos(arga) +
815 sa[np][8] * sin(arga)) * 1e-7;
816 for (k = 8; k < 10; k++) {
817 argl = kq[np][k] * dmu;
818 dl += t * (cl[np][k] * cos(argl) +
819 sl[np][k] * sin(argl)) * 1e-7;
821 dl = fmod(dl,
TWOPI);
825 ae = am + de * sin(am);
828 while (k < KMAX && fabs(dae) > 1e-12) {
829 dae = (am - ae + de * sin(ae)) / (1.0 - de * cos(ae));
832 if (k == KMAX-1) jstat = 2;
837 at = 2.0 * atan2(sqrt((1.0 + de) / (1.0 - de)) * sin(ae2),
841 r = da * (1.0 - de * cos(ae));
842 v = GK * sqrt((1.0 + 1.0 / amas[np]) / (da * da * da));
850 xm2 = 2.0 * (xp * xcw - xq * xsw);
852 xf = da / sqrt(1 - de * de);
853 xms = (de * sin(dp) + xsw) * xf;
854 xmc = (de * cos(dp) + xcw) * xf;
858 x = r * (xcw - xm2 * xp);
859 y = r * (xsw + xm2 * xq);
860 z = r * (-xm2 * ci2);
864 j2kV_au->a[1] = y * COSEPS - z * SINEPS;
865 j2kV_au->a[2] = y * SINEPS + z * COSEPS;
868 if (velV_aupd != NULL) {
869 x = v * (( -1.0 + 2.0 * xp * xp) * xms + xpxq2 * xmc);
870 y = v * (( 1.0 - 2.0 * xq * xq) * xmc - xpxq2 * xms);
871 z = v * (2.0 * ci2 * (xp * xms + xq * xmc));
875 velV_aupd->a[1] = y * COSEPS - z * SINEPS;
876 velV_aupd->a[2] = y * SINEPS + z * COSEPS;
989 LOCAL int planetGetEarth(
double t_cy,