1 | /* aberration, Jean Meeus, "Astronomical Algorithms", Willman-Bell, 1995;
|
---|
2 | * based on secular unperturbed Kepler orbit
|
---|
3 | *
|
---|
4 | * the corrections should be applied to ra/dec and lam/beta of the
|
---|
5 | * epoch of date.
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include <stdio.h>
|
---|
9 | #include <math.h>
|
---|
10 |
|
---|
11 | #if defined(__STDC__)
|
---|
12 | #include <stdlib.h>
|
---|
13 | #endif
|
---|
14 |
|
---|
15 | #include "P_.h"
|
---|
16 | #include "astro.h"
|
---|
17 |
|
---|
18 | #define ABERR_CONST (20.49552/3600./180.*PI) /* aberr const in rad */
|
---|
19 | #define AB_ECL_EOD 0
|
---|
20 | #define AB_EQ_EOD 1
|
---|
21 |
|
---|
22 | static void ab_aux P_((double mjd, double *x, double *y, double lsn,
|
---|
23 | int mode));
|
---|
24 |
|
---|
25 | /* apply aberration correction to ecliptical coordinates *lam and *bet
|
---|
26 | * (in radians) for a given time mjd and handily supplied longitude of sun,
|
---|
27 | * lsn (in radians)
|
---|
28 | */
|
---|
29 | void
|
---|
30 | ab_ecl (mjd, lsn, lam, bet)
|
---|
31 | double mjd, lsn, *lam, *bet;
|
---|
32 | {
|
---|
33 | ab_aux(mjd, lam, bet, lsn, AB_ECL_EOD);
|
---|
34 | }
|
---|
35 |
|
---|
36 | /* apply aberration correction to equatoreal coordinates *ra and *dec
|
---|
37 | * (in radians) for a given time mjd and handily supplied longitude of sun,
|
---|
38 | * lsn (in radians)
|
---|
39 | */
|
---|
40 | void
|
---|
41 | ab_eq (mjd, lsn, ra, dec)
|
---|
42 | double mjd, lsn, *ra, *dec;
|
---|
43 | {
|
---|
44 | ab_aux(mjd, ra, dec, lsn, AB_EQ_EOD);
|
---|
45 | }
|
---|
46 |
|
---|
47 | /* because the e-terms are secular, keep the real transformation for both
|
---|
48 | * coordinate systems in here with the secular variables cached.
|
---|
49 | * mode == AB_ECL_EOD: x = lam, y = bet (ecliptical)
|
---|
50 | * mode == AB_EQ_EOD: x = ra, y = dec (equatoreal)
|
---|
51 | */
|
---|
52 | static void
|
---|
53 | ab_aux (mjd, x, y, lsn, mode)
|
---|
54 | double mjd, *x, *y, lsn;
|
---|
55 | int mode;
|
---|
56 | {
|
---|
57 | static double lastmjd = -10000;
|
---|
58 | static double eexc; /* earth orbit excentricity */
|
---|
59 | static double leperi; /* ... and longitude of perihelion */
|
---|
60 | static char dirty = 1; /* flag for cached trig terms */
|
---|
61 |
|
---|
62 | if (mjd != lastmjd) {
|
---|
63 | double T; /* centuries since J2000 */
|
---|
64 |
|
---|
65 | T = (mjd - J2000)/36525.;
|
---|
66 | eexc = 0.016708617 - (42.037e-6 + 0.1236e-6 * T) * T;
|
---|
67 | leperi = degrad(102.93735 + (0.71953 + 0.00046 * T) * T);
|
---|
68 | lastmjd = mjd;
|
---|
69 | dirty = 1;
|
---|
70 | }
|
---|
71 |
|
---|
72 | switch (mode) {
|
---|
73 | case AB_ECL_EOD: /* ecliptical coords */
|
---|
74 | {
|
---|
75 | double *lam = x, *bet = y;
|
---|
76 | double dlsun, dlperi;
|
---|
77 |
|
---|
78 | dlsun = lsn - *lam;
|
---|
79 | dlperi = leperi - *lam;
|
---|
80 |
|
---|
81 | /* valid only for *bet != +-PI/2 */
|
---|
82 | *lam -= ABERR_CONST/cos(*bet) * (cos(dlsun) -
|
---|
83 | eexc*cos(dlperi));
|
---|
84 | *bet -= ABERR_CONST*sin(*bet) * (sin(dlsun) -
|
---|
85 | eexc*sin(dlperi));
|
---|
86 | }
|
---|
87 | break;
|
---|
88 |
|
---|
89 | case AB_EQ_EOD: /* equatoreal coords */
|
---|
90 | {
|
---|
91 | double *ra = x, *dec = y;
|
---|
92 | double sr, cr, sd, cd, sls, cls;/* trig values coords */
|
---|
93 | static double cp, sp, ce, se; /* .. and perihel/eclipic */
|
---|
94 | double dra, ddec; /* changes in ra and dec */
|
---|
95 |
|
---|
96 | if (dirty) {
|
---|
97 | double eps;
|
---|
98 |
|
---|
99 | cp = cos(leperi);
|
---|
100 | sp = sin(leperi);
|
---|
101 | obliquity(mjd, &eps);
|
---|
102 | se = sin(eps);
|
---|
103 | ce = cos(eps);
|
---|
104 | dirty = 0;
|
---|
105 | }
|
---|
106 |
|
---|
107 | sr = sin(*ra);
|
---|
108 | cr = cos(*ra);
|
---|
109 | sd = sin(*dec);
|
---|
110 | cd = cos(*dec);
|
---|
111 | sls = sin(lsn);
|
---|
112 | cls = cos(lsn);
|
---|
113 |
|
---|
114 | dra = ABERR_CONST/cd * ( -(cr * cls * ce + sr * sls) +
|
---|
115 | eexc * (cr * cp * ce + sr * sp));
|
---|
116 |
|
---|
117 | ddec = se/ce * cd - sr * sd; /* tmp use */
|
---|
118 | ddec = ABERR_CONST * ( -(cls * ce * ddec + cr * sd * sls) +
|
---|
119 | eexc * (cp * ce * ddec + cr * sd * sp) );
|
---|
120 |
|
---|
121 | *ra += dra;
|
---|
122 | range (ra, 2*PI);
|
---|
123 | *dec += ddec;
|
---|
124 | }
|
---|
125 | break;
|
---|
126 |
|
---|
127 | default:
|
---|
128 | printf ("ab_aux: bad mode: %d\n", mode);
|
---|
129 | exit (1);
|
---|
130 | break;
|
---|
131 |
|
---|
132 | } /* switch (mode) */
|
---|
133 | }
|
---|
134 |
|
---|
135 | /* For RCS Only -- Do Not Edit */
|
---|
136 | static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: aberration.c,v $ $Date: 2001-04-10 14:40:45 $ $Revision: 1.1.1.1 $ $Name: not supported by cvs2svn $"};
|
---|