| [1457] | 1 | /* heliocentric rectangular equatorial coordinates of Jupiter to Pluto; | 
|---|
|  | 2 | * from Chapront's expansion of DE200/extension of DE200;  mean equator J2000.0 | 
|---|
|  | 3 | * | 
|---|
|  | 4 | * calculation time (milliseconds) on an HP 715/75, Jupiter to Pluto: | 
|---|
|  | 5 | * (each coordinate component counted as 1 term, | 
|---|
|  | 6 | * secular terms included for JD 2448908.5 = 1992 Oct 13.0) | 
|---|
|  | 7 | * | 
|---|
|  | 8 | *      prec    terms   rates   no rates | 
|---|
|  | 9 | *      0.0     2256    5.1     4.6 | 
|---|
|  | 10 | * | 
|---|
|  | 11 | *      1e-7    792     2.6     2.4     --> nominal precision rel. to DE200 | 
|---|
|  | 12 | *      1e-6    535     2.1     2.0 | 
|---|
|  | 13 | *      1e-5    350     1.8     1.6 | 
|---|
|  | 14 | *      1e-4    199     1.5     1.4 | 
|---|
|  | 15 | *      1e-3    96      1.2     1.1 | 
|---|
|  | 16 | * | 
|---|
|  | 17 | *      no drop 2256    4.5     3.9     (code without test criterion) | 
|---|
|  | 18 | */ | 
|---|
|  | 19 |  | 
|---|
|  | 20 | #include <math.h> | 
|---|
|  | 21 | #include "P_.h" | 
|---|
|  | 22 | #include "astro.h" | 
|---|
|  | 23 | #include "chap95.h" | 
|---|
|  | 24 |  | 
|---|
|  | 25 | extern void zero_mem P_((void *loc, unsigned len)); | 
|---|
|  | 26 |  | 
|---|
|  | 27 | #define CHAP_MAXTPOW    2       /* NB: valid for all 5 outer planets */ | 
|---|
|  | 28 |  | 
|---|
|  | 29 | /* chap95() | 
|---|
|  | 30 | * | 
|---|
|  | 31 | * input: | 
|---|
|  | 32 | *      mjd     modified JD; days from J1900.0 = 2415020.0 | 
|---|
|  | 33 | * | 
|---|
|  | 34 | *      prec    precision level, in radians. | 
|---|
|  | 35 | *              if (prec = 0.0), you get the full precision, namely | 
|---|
|  | 36 | *              a deviation of not more than 0.02 arc seconds (1e-7 rad) | 
|---|
|  | 37 | *              from the JPL DE200 integration, on which this expansion | 
|---|
|  | 38 | *              is based. | 
|---|
|  | 39 | * | 
|---|
|  | 40 | *      obj     object number as in astro.h (jupiter=3, saturn=4, ...) | 
|---|
|  | 41 | * | 
|---|
|  | 42 | * output: | 
|---|
|  | 43 | *      ret[6]  cartesian components of position and velocity | 
|---|
|  | 44 | * | 
|---|
|  | 45 | * return: | 
|---|
|  | 46 | *      0       Ok | 
|---|
|  | 47 | *      1       time out of range [CHAP_BEGIN .. CHAP_END] | 
|---|
|  | 48 | *      2       object out of range [JUPITER .. PLUTO] | 
|---|
|  | 49 | *      3       precision out of range [0.0 .. 1e-3] | 
|---|
|  | 50 | */ | 
|---|
|  | 51 | int | 
|---|
|  | 52 | chap95 (mjd, obj, prec, ret) | 
|---|
|  | 53 | double mjd; | 
|---|
|  | 54 | int obj; | 
|---|
|  | 55 | double prec; | 
|---|
|  | 56 | double *ret; | 
|---|
|  | 57 | { | 
|---|
|  | 58 | static double a0[] = {          /* semimajor axes for precision ctrl */ | 
|---|
|  | 59 | 0.39, 0.72, 1.5, 5.2, 9.6, 19.2, 30.1, 39.5, 1.0 | 
|---|
|  | 60 | }; | 
|---|
|  | 61 | double sum[CHAP_MAXTPOW+1][6];  /* [T^0, ..][X,Y,Z,X',Y',Z'] */ | 
|---|
|  | 62 | double T, t;                    /* time in centuries and years */ | 
|---|
|  | 63 | double ca, sa, Nu;              /* aux vars for terms */ | 
|---|
|  | 64 | double precT[CHAP_MAXTPOW+1];   /* T-augmented precision threshold */ | 
|---|
|  | 65 | chap95_rec *rec;                /* term coeffs */ | 
|---|
|  | 66 | int cooidx; | 
|---|
|  | 67 |  | 
|---|
|  | 68 | /* check parameters */ | 
|---|
|  | 69 | if (mjd < CHAP_BEGIN || mjd > CHAP_END) | 
|---|
|  | 70 | return (1); | 
|---|
|  | 71 |  | 
|---|
|  | 72 | if (obj < JUPITER || obj > PLUTO) | 
|---|
|  | 73 | return (2); | 
|---|
|  | 74 |  | 
|---|
|  | 75 | if (prec < 0.0 || prec > 1e-3) | 
|---|
|  | 76 | return (3); | 
|---|
|  | 77 |  | 
|---|
|  | 78 | /* init the sums */ | 
|---|
|  | 79 | zero_mem ((void *)sum, sizeof(sum)); | 
|---|
|  | 80 |  | 
|---|
|  | 81 | T = (mjd - J2000)/36525.0;      /* centuries since J2000.0 */ | 
|---|
|  | 82 |  | 
|---|
|  | 83 | /* modify precision treshold for | 
|---|
|  | 84 | * a) term storing scale | 
|---|
|  | 85 | * b) convert radians to au | 
|---|
|  | 86 | * c) account for skipped terms (more terms needed for better prec) | 
|---|
|  | 87 | *    threshold empirically established similar to VSOP; stern | 
|---|
|  | 88 | * d) augment for secular terms | 
|---|
|  | 89 | */ | 
|---|
|  | 90 | precT[0] = prec * CHAP_SCALE                            /* a) */ | 
|---|
|  | 91 | * a0[obj]                               /* b) */ | 
|---|
|  | 92 | / (10. * (-log10(prec + 1e-35) - 2));   /* c) */ | 
|---|
|  | 93 | t = 1./(fabs(T) + 1e-35);                               /* d) */ | 
|---|
|  | 94 | precT[1] = precT[0]*t; | 
|---|
|  | 95 | precT[2] = precT[1]*t; | 
|---|
|  | 96 |  | 
|---|
|  | 97 | t = T * 100.0;          /* YEARS since J2000.0 */ | 
|---|
|  | 98 |  | 
|---|
|  | 99 | ca = sa = Nu = 0.;      /* shut up compiler warning 'uninitialised' */ | 
|---|
|  | 100 |  | 
|---|
|  | 101 | switch (obj) {          /* set initial term record pointer */ | 
|---|
|  | 102 | case JUPITER:       rec = chap95_jupiter;   break; | 
|---|
|  | 103 | case SATURN:        rec = chap95_saturn;    break; | 
|---|
|  | 104 | case URANUS:        rec = chap95_uranus;    break; | 
|---|
|  | 105 | case NEPTUNE:       rec = chap95_neptune;   break; | 
|---|
|  | 106 | case PLUTO:         rec = chap95_pluto;     break; | 
|---|
|  | 107 | default: | 
|---|
|  | 108 | return (2);     /* wrong object: severe internal trouble */ | 
|---|
|  | 109 | } | 
|---|
|  | 110 |  | 
|---|
|  | 111 | /* do the term summation into sum[T^n] slots */ | 
|---|
|  | 112 | for (; rec->n >= 0; ++rec) { | 
|---|
|  | 113 | double *amp; | 
|---|
|  | 114 |  | 
|---|
|  | 115 | /* NOTE:  The formula | 
|---|
|  | 116 | * X = SUM[i=1,Records] T**n_i*(CX_i*cos(Nu_k*t)+SX_i*sin(Nu_k*t)) | 
|---|
|  | 117 | * could be rewritten as  SUM( ... A sin (B + C*t) ) | 
|---|
|  | 118 | * "saving" trigonometric calls.  However, e.g. for Pluto, | 
|---|
|  | 119 | * there are only 65 distinct angles NU_k (130 trig calls). | 
|---|
|  | 120 | * With that manipulation, EVERY arg_i would be different for X, | 
|---|
|  | 121 | * Y and Z, which is 3*96 terms.  Hence, the formulation as | 
|---|
|  | 122 | * given is good (optimal?). | 
|---|
|  | 123 | */ | 
|---|
|  | 124 |  | 
|---|
|  | 125 | for (cooidx = 0, amp = rec->amp; cooidx < 3; ++cooidx) { | 
|---|
|  | 126 | double C, S, term, termdot; | 
|---|
|  | 127 | short n;                /* fast access */ | 
|---|
|  | 128 |  | 
|---|
|  | 129 | C = *amp++; | 
|---|
|  | 130 | S = *amp++; | 
|---|
|  | 131 | n = rec->n; | 
|---|
|  | 132 |  | 
|---|
|  | 133 | /* drop term if too small | 
|---|
|  | 134 | * this is quite expensive:  17% of loop time | 
|---|
|  | 135 | */ | 
|---|
|  | 136 | if (fabs(C) + fabs(S) < precT[n]) | 
|---|
|  | 137 | continue; | 
|---|
|  | 138 |  | 
|---|
|  | 139 | if (n == 0 && cooidx == 0) {    /* new Nu only here */ | 
|---|
|  | 140 | double arg; | 
|---|
|  | 141 |  | 
|---|
|  | 142 | Nu = rec->Nu; | 
|---|
|  | 143 | arg = Nu * t; | 
|---|
|  | 144 | arg -= floor(arg/(2.*PI))*(2.*PI); | 
|---|
|  | 145 | ca = cos(arg);      /* blast it - even for Nu = 0.0 */ | 
|---|
|  | 146 | sa = sin(arg); | 
|---|
|  | 147 | } | 
|---|
|  | 148 |  | 
|---|
|  | 149 | term = C * ca + S * sa; | 
|---|
|  | 150 | sum[n][cooidx] += term; | 
|---|
|  | 151 | #if CHAP_GETRATE | 
|---|
|  | 152 | termdot = (-C * sa + S * ca) * Nu; | 
|---|
|  | 153 | sum[n][cooidx+3] += termdot; | 
|---|
|  | 154 | if (n > 0) sum[n - 1][cooidx+3] += n/100.0 * term; | 
|---|
|  | 155 | #endif | 
|---|
|  | 156 | } /* cooidx */ | 
|---|
|  | 157 | } /* records */ | 
|---|
|  | 158 |  | 
|---|
|  | 159 | /* apply powers of time and sum up */ | 
|---|
|  | 160 | for (cooidx = 0; cooidx < 6; ++cooidx) { | 
|---|
|  | 161 | ret[cooidx] = (sum[0][cooidx] + | 
|---|
|  | 162 | T * (sum[1][cooidx] + | 
|---|
|  | 163 | T * (sum[2][cooidx] )) )/CHAP_SCALE; | 
|---|
|  | 164 | } | 
|---|
|  | 165 |  | 
|---|
|  | 166 | /* TEST: if the MAIN terms are dropped, get angular residue | 
|---|
|  | 167 | ret[0] = sqrt(ret[0]*ret[0] + ret[1]*ret[1] + ret[2]*ret[2])/a0[obj]; | 
|---|
|  | 168 | */ | 
|---|
|  | 169 |  | 
|---|
|  | 170 | #if CHAP_GETRATE | 
|---|
|  | 171 | for (cooidx = 3; cooidx < 6; ++cooidx) { | 
|---|
|  | 172 | ret[cooidx] /= 365.25;      /* yearly to daily rate */ | 
|---|
|  | 173 | } | 
|---|
|  | 174 | #endif | 
|---|
|  | 175 |  | 
|---|
|  | 176 | return (0); | 
|---|
|  | 177 | } | 
|---|
|  | 178 |  | 
|---|
|  | 179 | /* For RCS Only -- Do Not Edit */ | 
|---|
| [1719] | 180 | static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: chap95.c,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"}; | 
|---|