00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef _NOVAS_
00016 #include "novas.h"
00017 #endif
00018
00019 #include <math.h>
00020
00021
00022
00023
00024
00025
00026 void sun_eph (double jd,
00027
00028 double *ra, double *dec, double *dis);
00029
00030
00031
00032
00033
00034 short int solarsystem (double tjd, short int body, short int origin,
00035
00036 double *pos, double *vel)
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 {
00109 short int ierr = 0;
00110 short int i;
00111
00112
00113
00114
00115
00116
00117
00118 const double pm[4] = {1047.349, 3497.898, 22903.0, 19412.2};
00119 const double pa[4] = {5.203363, 9.537070, 19.191264, 30.068963};
00120 const double pl[4] = {0.600470, 0.871693, 5.466933, 5.321160};
00121 const double pn[4] = {1.450138e-3, 5.841727e-4, 2.047497e-4,
00122 1.043891e-4};
00123
00124
00125
00126
00127
00128 const double obl = 23.43929111;
00129
00130 static double tlast = 0.0;
00131 static double sine, cose, tmass, pbary[3], vbary[3];
00132
00133 double oblr, qjd, ras, decs, diss, pos1[3], p[3][3], dlon, sinl,
00134 cosl, x, y, z, xdot, ydot, zdot, f;
00135
00136
00137
00138
00139
00140 if (tlast == 0.0)
00141 {
00142 oblr = obl * TWOPI / 360.0;
00143 sine = sin (oblr);
00144 cose = cos (oblr);
00145 tmass = 1.0;
00146 for (i = 0; i < 4; i++)
00147 tmass += 1.0 / pm[i];
00148 tlast = 1.0;
00149 }
00150
00151
00152
00153
00154
00155 if ((tjd < 2340000.5) || (tjd > 2560000.5))
00156 return (ierr = 1);
00157
00158
00159
00160
00161
00162
00163 if ((body == 0) || (body == 1) || (body == 10))
00164 for (i = 0; i < 3; i++)
00165 pos[i] = vel[i] = 0.0;
00166
00167 else if ((body == 2) || (body == 3))
00168 {
00169 for (i = 0; i < 3; i++)
00170 {
00171 qjd = tjd + (double) (i - 1) * 0.1;
00172 sun_eph (qjd, &ras,&decs,&diss);
00173 radec2vector (ras,decs,diss, pos1);
00174 precession (qjd,pos1,T0, pos);
00175 p[i][0] = -pos[0];
00176 p[i][1] = -pos[1];
00177 p[i][2] = -pos[2];
00178 }
00179 for (i = 0; i < 3; i++)
00180 {
00181 pos[i] = p[1][i];
00182 vel[i] = (p[2][i] - p[0][i]) / 0.2;
00183 }
00184 }
00185
00186 else
00187 return (ierr = 2);
00188
00189
00190
00191
00192
00193
00194
00195
00196 if (origin == 0)
00197 {
00198 if (fabs (tjd - tlast) >= 1.0e-06)
00199 {
00200 for (i = 0; i < 3; i++)
00201 pbary[i] = vbary[i] = 0.0;
00202
00203
00204
00205
00206
00207
00208
00209
00210 for (i = 0; i < 4; i++)
00211 {
00212 dlon = pl[i] + pn[i] * (tjd - T0);
00213 dlon = fmod (dlon, TWOPI);
00214 sinl = sin (dlon);
00215 cosl = cos (dlon);
00216
00217 x = pa[i] * cosl;
00218 y = pa[i] * sinl * cose;
00219 z = pa[i] * sinl * sine;
00220 xdot = -pa[i] * pn[i] * sinl;
00221 ydot = pa[i] * pn[i] * cosl * cose;
00222 zdot = pa[i] * pn[i] * cosl * sine;
00223
00224 f = 1.0 / (pm[i] * tmass);
00225
00226 pbary[0] += x * f;
00227 pbary[1] += y * f;
00228 pbary[2] += z * f;
00229 vbary[0] += xdot * f;
00230 vbary[1] += ydot * f;
00231 vbary[2] += zdot * f;
00232 }
00233
00234 tlast = tjd;
00235 }
00236
00237 for (i = 0; i < 3; i++)
00238 {
00239 pos[i] -= pbary[i];
00240 vel[i] -= vbary[i];
00241 }
00242 }
00243
00244 return (ierr);
00245 }
00246
00247
00248
00249 void sun_eph (double jd,
00250
00251 double *ra, double *dec, double *dis)
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308 {
00309 short int i;
00310
00311 double sum_lon = 0.0;
00312 double sum_r = 0.0;
00313 const double factor = 1.0e-07;
00314 double u, arg, lon, lat, t, t2, emean, sin_lon;
00315
00316 struct sun_con
00317 {
00318 double l;
00319 double r;
00320 double alpha;
00321 double nu;
00322 };
00323
00324 static const struct sun_con con[50] =
00325 {{403406.0, 0.0, 4.721964, 1.621043},
00326 {195207.0, -97597.0, 5.937458, 62830.348067},
00327 {119433.0, -59715.0, 1.115589, 62830.821524},
00328 {112392.0, -56188.0, 5.781616, 62829.634302},
00329 { 3891.0, -1556.0, 5.5474 , 125660.5691 },
00330 { 2819.0, -1126.0, 1.5120 , 125660.9845 },
00331 { 1721.0, -861.0, 4.1897 , 62832.4766 },
00332 { 0.0, 941.0, 1.163 , 0.813 },
00333 { 660.0, -264.0, 5.415 , 125659.310 },
00334 { 350.0, -163.0, 4.315 , 57533.850 },
00335 { 334.0, 0.0, 4.553 , -33.931 },
00336 { 314.0, 309.0, 5.198 , 777137.715 },
00337 { 268.0, -158.0, 5.989 , 78604.191 },
00338 { 242.0, 0.0, 2.911 , 5.412 },
00339 { 234.0, -54.0, 1.423 , 39302.098 },
00340 { 158.0, 0.0, 0.061 , -34.861 },
00341 { 132.0, -93.0, 2.317 , 115067.698 },
00342 { 129.0, -20.0, 3.193 , 15774.337 },
00343 { 114.0, 0.0, 2.828 , 5296.670 },
00344 { 99.0, -47.0, 0.52 , 58849.27 },
00345 { 93.0, 0.0, 4.65 , 5296.11 },
00346 { 86.0, 0.0, 4.35 , -3980.70 },
00347 { 78.0, -33.0, 2.75 , 52237.69 },
00348 { 72.0, -32.0, 4.50 , 55076.47 },
00349 { 68.0, 0.0, 3.23 , 261.08 },
00350 { 64.0, -10.0, 1.22 , 15773.85 },
00351 { 46.0, -16.0, 0.14 , 188491.03 },
00352 { 38.0, 0.0, 3.44 , -7756.55 },
00353 { 37.0, 0.0, 4.37 , 264.89 },
00354 { 32.0, -24.0, 1.14 , 117906.27 },
00355 { 29.0, -13.0, 2.84 , 55075.75 },
00356 { 28.0, 0.0, 5.96 , -7961.39 },
00357 { 27.0, -9.0, 5.09 , 188489.81 },
00358 { 27.0, 0.0, 1.72 , 2132.19 },
00359 { 25.0, -17.0, 2.56 , 109771.03 },
00360 { 24.0, -11.0, 1.92 , 54868.56 },
00361 { 21.0, 0.0, 0.09 , 25443.93 },
00362 { 21.0, 31.0, 5.98 , -55731.43 },
00363 { 20.0, -10.0, 4.03 , 60697.74 },
00364 { 18.0, 0.0, 4.27 , 2132.79 },
00365 { 17.0, -12.0, 0.79 , 109771.63 },
00366 { 14.0, 0.0, 4.24 , -7752.82 },
00367 { 13.0, -5.0, 2.01 , 188491.91 },
00368 { 13.0, 0.0, 2.65 , 207.81 },
00369 { 13.0, 0.0, 4.98 , 29424.63 },
00370 { 12.0, 0.0, 0.93 , -7.99 },
00371 { 10.0, 0.0, 2.21 , 46941.14 },
00372 { 10.0, 0.0, 3.59 , -68.29 },
00373 { 10.0, 0.0, 1.50 , 21463.25 },
00374 { 10.0, -9.0, 2.55 , 157208.40 }};
00375
00376
00377
00378
00379
00380
00381 u = (jd - T0) / 3652500.0;
00382
00383
00384
00385
00386
00387 for (i = 0; i < 50; i++)
00388 {
00389 arg = con[i].alpha + con[i].nu * u;
00390 sum_lon += con[i].l * sin (arg);
00391 sum_r += con[i].r * cos (arg);
00392 }
00393
00394
00395
00396
00397
00398
00399 lon = 4.9353929 + 62833.1961680 * u + factor * sum_lon;
00400
00401 lon = fmod (lon, TWOPI);
00402 if (lon < 0.0)
00403 lon += TWOPI;
00404
00405 lat = 0.0;
00406
00407 *dis = 1.0001026 + factor * sum_r;
00408
00409
00410
00411
00412
00413 t = u * 100.0;
00414 t2 = t * t;
00415 emean = (0.001813 * t2 * t - 0.00059 * t2 - 46.8150 * t +
00416 84381.448) / RAD2SEC;
00417
00418
00419
00420
00421
00422
00423 sin_lon = sin (lon);
00424 *ra = atan2 ((cos (emean) * sin_lon), cos (lon)) * RAD2DEG;
00425 *ra = fmod (*ra, 360.0);
00426 if (*ra < 0.0)
00427 *ra += 360.0;
00428 *ra = *ra / 15.0;
00429
00430 *dec = asin (sin (emean) * sin_lon) * RAD2DEG;
00431
00432 return;
00433 }