2
This program is free software; you can redistribute it and/or modify
3
it under the terms of the GNU Library General Public License as published by
4
the Free Software Foundation; either version 2 of the License, or
5
(at your option) any later version.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
Copyright (C) 2000 Liam Girdwood <liam@nova-ioe.org>
24
#define LN_NUTATION_EPOCH_THRESHOLD 0.1
26
/* arguments and coefficients taken from table 21A on page 133 */
28
const static struct nutation_arguments arguments[TERMS] = {
29
{0.0, 0.0, 0.0, 0.0, 1.0},
30
{-2.0, 0.0, 0.0, 2.0, 2.0},
31
{0.0, 0.0, 0.0, 2.0, 2.0},
32
{0.0, 0.0, 0.0, 0.0, 2.0},
33
{0.0, 1.0, 0.0, 0.0, 0.0},
34
{0.0, 0.0, 1.0, 0.0, 0.0},
35
{-2.0, 1.0, 0.0, 2.0, 2.0},
36
{0.0, 0.0, 0.0, 2.0, 1.0},
37
{0.0, 0.0, 1.0, 2.0, 2.0},
38
{-2.0, -1.0, 0.0, 2.0, 2.0},
39
{-2.0, 0.0, 1.0, 0.0, 0.0},
40
{-2.0, 0.0, 0.0, 2.0, 1.0},
41
{0.0, 0.0, -1.0, 2.0, 2.0},
42
{2.0, 0.0, 0.0, 0.0, 0.0},
43
{0.0, 0.0, 1.0, 0.0, 1.0},
44
{2.0, 0.0, -1.0, 2.0, 2.0},
45
{0.0, 0.0, -1.0, 0.0, 1.0},
46
{0.0, 0.0, 1.0, 2.0, 1.0},
47
{-2.0, 0.0, 2.0, 0.0, 0.0},
48
{0.0, 0.0, -2.0, 2.0, 1.0},
49
{2.0, 0.0, 0.0, 2.0, 2.0},
50
{0.0, 0.0, 2.0, 2.0, 2.0},
51
{0.0, 0.0, 2.0, 0.0, 0.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
88
{0.0, -1.0, 1.0, 2.0, 2.0},
89
{2.0, -1.0, -1.0, 2.0, 2.0},
90
{0.0, 0.0, 3.0, 2.0, 2.0},
91
{2.0, -1.0, 0.0, 2.0, 2.0}};
93
const static struct nutation_coefficients coefficients[TERMS] = {
94
{-171996.0, -174.2, 92025.0,8.9},
95
{-13187.0, -1.6, 5736.0, -3.1},
96
{-2274.0, 0.2, 977.0, -0.5},
97
{2062.0, 0.2, -895.0, 0.5},
98
{1426.0, -3.4, 54.0, -0.1},
99
{712.0, 0.1, -7.0, 0.0},
100
{-517.0, 1.2, 224.0, -0.6},
101
{-386.0, -0.4, 200.0, 0.0},
102
{-301.0, 0.0, 129.0, -0.1},
103
{217.0, -0.5, -95.0, 0.3},
104
{-158.0, 0.0, 0.0, 0.0},
105
{129.0, 0.1, -70.0, 0.0},
106
{123.0, 0.0, -53.0, 0.0},
107
{63.0, 0.0, 0.0, 0.0},
108
{63.0, 1.0, -33.0, 0.0},
109
{-59.0, 0.0, 26.0, 0.0},
110
{-58.0, -0.1, 32.0, 0.0},
111
{-51.0, 0.0, 27.0, 0.0},
112
{48.0, 0.0, 0.0, 0.0},
113
{46.0, 0.0, -24.0, 0.0},
114
{-38.0, 0.0, 16.0, 0.0},
115
{-31.0, 0.0, 13.0, 0.0},
116
{29.0, 0.0, 0.0, 0.0},
117
{29.0, 0.0, -12.0, 0.0},
118
{26.0, 0.0, 0.0, 0.0},
119
{-22.0, 0.0, 0.0, 0.0},
120
{21.0, 0.0, -10.0, 0.0},
121
{17.0, -0.1, 0.0, 0.0},
122
{16.0, 0.0, -8.0, 0.0},
123
{-16.0, 0.1, 7.0, 0.0},
124
{-15.0, 0.0, 9.0, 0.0},
125
{-13.0, 0.0, 7.0, 0.0},
126
{-12.0, 0.0, 6.0, 0.0},
127
{11.0, 0.0, 0.0, 0.0},
128
{-10.0, 0.0, 5.0, 0.0},
129
{-8.0, 0.0, 3.0, 0.0},
130
{7.0, 0.0, -3.0, 0.0},
131
{-7.0, 0.0, 0.0, 0.0},
132
{-7.0, 0.0, 3.0, 0.0},
133
{-7.0, 0.0, 3.0, 0.0},
134
{6.0, 0.0, 0.0, 0.0},
135
{6.0, 0.0, -3.0, 0.0},
136
{6.0, 0.0, -3.0, 0.0},
137
{-6.0, 0.0, 3.0, 0.0},
138
{-6.0, 0.0, 3.0, 0.0},
139
{5.0, 0.0, 0.0, 0.0},
140
{-5.0, 0.0, 3.0, 0.0},
141
{-5.0, 0.0, 3.0, 0.0},
142
{-5.0, 0.0, 3.0, 0.0},
143
{4.0, 0.0, 0.0, 0.0},
144
{4.0, 0.0, 0.0, 0.0},
145
{4.0, 0.0, 0.0, 0.0},
146
{-4.0, 0.0, 0.0, 0.0},
147
{-4.0, 0.0, 0.0, 0.0},
148
{-4.0, 0.0, 0.0, 0.0},
149
{3.0, 0.0, 0.0, 0.0},
150
{-3.0, 0.0, 0.0, 0.0},
151
{-3.0, 0.0, 0.0, 0.0},
152
{-3.0, 0.0, 0.0, 0.0},
153
{-3.0, 0.0, 0.0, 0.0},
154
{-3.0, 0.0, 0.0, 0.0},
155
{-3.0, 0.0, 0.0, 0.0},
156
{-3.0, 0.0, 0.0, 0.0}};
159
static double c_JD = 0.0, c_longitude = 0.0, c_obliquity = 0.0, c_ecliptic = 0.0;
162
/* Calculate nutation of longitude and obliquity in degrees from Julian Ephemeris Day
163
* params : JD Julian Day, nutation Pointer to store nutation.
164
* Chapter 21 pg 131-134 Using Table 21A */
165
void get_nutation (double JD, struct ln_nutation * nutation)
168
double D,M,MM,F,O,T,T2,T3;
169
double coeff_sine, coeff_cos;
172
/* should we bother recalculating nutation */
173
if (fabs(JD - c_JD) > LN_NUTATION_EPOCH_THRESHOLD)
175
/* set the new epoch */
179
c_ecliptic = 23.0 + 26.0 / 60.0 + 27.407 / 3600.0;
182
T = (JD - 2451545.0)/36525;
186
/* calculate D,M,M',F and Omega */
187
D = 297.85036 + 445267.111480 * T - 0.0019142 * T2 + T3 / 189474.0;
188
M = 357.52772 + 35999.050340 * T - 0.0001603 * T2 - T3 / 300000.0;
189
MM = 134.96298 + 477198.867398 * T + 0.0086972 * T2 + T3 / 56250.0;
190
F = 93.2719100 + 483202.017538 * T - 0.0036825 * T2 + T3 / 327270.0;
191
O = 125.04452 - 1934.136261 * T + 0.0020708 * T2 + T3 / 450000.0;
193
/* convert to radians */
200
/* calc sum of terms in table 21A */
201
for (i=0; i< TERMS; i++)
203
/* calc coefficients of sine and cosine */
204
coeff_sine = (coefficients[i].longitude1 + (coefficients[i].longitude2 * T));
205
coeff_cos = (coefficients[i].obliquity1 + (coefficients[i].obliquity2 * T));
207
/* sum the arguments */
208
if (arguments[i].D != 0)
210
c_longitude += coeff_sine * (sin (arguments[i].D * D));
211
c_obliquity += coeff_cos * (cos (arguments[i].D * D));
213
if (arguments[i].M != 0)
215
c_longitude += coeff_sine * (sin (arguments[i].M * M));
216
c_obliquity += coeff_cos * (cos (arguments[i].M * M));
218
if (arguments[i].MM != 0)
220
c_longitude += coeff_sine * (sin (arguments[i].MM * MM));
221
c_obliquity += coeff_cos * (cos (arguments[i].MM * MM));
223
if (arguments[i].F != 0)
225
c_longitude += coeff_sine * (sin (arguments[i].F * F));
226
c_obliquity += coeff_cos * (cos (arguments[i].F * F));
228
if (arguments[i].O != 0)
230
c_longitude += coeff_sine * (sin (arguments[i].O * O));
231
c_obliquity += coeff_cos * (cos (arguments[i].O * O));
235
/* change to degrees */
236
c_longitude /= 36000000.;
237
c_obliquity /= 36000000.;
239
c_ecliptic += c_obliquity;
243
nutation->longitude = c_longitude;
244
nutation->obliquity = c_obliquity;
245
nutation->ecliptic = c_ecliptic;