UNPKG

11.5 kBJavaScriptView Raw
1/**
2 * @copyright 2013 Sonia Keys
3 * @copyright 2016 commenthol
4 * @license MIT
5 * @module planetary
6 */
7/**
8 * Planetary: Chapter 36, The Calculation of some Planetary Phenomena.
9 *
10 * Incomplete: Some functions unimplemented for lack of test data.
11 */
12
13import base from './base';
14
15/**
16 * Mean computes some intermediate values for a mean planetary configuration
17 * given a year and a row of coefficients from Table 36.A, p. 250.0
18 */
19export function mean(y, a) {
20 // (y float64, a *ca) (J, M, T float64)
21 // (36.1) p. 250
22 var k = Math.floor((365.2425 * y + 1721060 - a.A) / a.B + 0.5);
23 var J = a.A + k * a.B;
24 var M = base.pmod(a.M0 + k * a.M1, 360) * Math.PI / 180;
25 var T = base.J2000Century(J);
26 return [J, M, T];
27}
28
29/**
30 * Sum computes a sum of periodic terms.
31 */
32export function sum(T, M, c) {
33 // (T, M float64, c [][]float64) float64
34 var j = base.horner(T, c[0]);
35 var mm = 0.0;
36 for (var i = 1; i < c.length; i++) {
37 mm += M;
38
39 var _base$sincos = base.sincos(mm),
40 smm = _base$sincos[0],
41 cmm = _base$sincos[1];
42
43 j += smm * base.horner(T, c[i]);
44 i++;
45 j += cmm * base.horner(T, c[i]);
46 }
47 return j;
48}
49
50/**
51 * ms returns a mean time corrected by a sum.
52 */
53export function ms(y, a, c) {
54 // (y float64, a *ca, c [][]float64) float64
55 var _mean = mean(y, a),
56 J = _mean[0],
57 M = _mean[1],
58 T = _mean[2];
59
60 return J + sum(T, M, c);
61}
62
63/**
64 * MercuryInfConj returns the time of an inferior conjunction of Mercury.
65 *
66 * Result is time (as a jde) of the event nearest the given time (as a
67 * decimal year.)
68 */
69export function mercuryInfConj(y) {
70 // (y float64) (jde float64)
71 return ms(y, micA, micB);
72}
73
74/**
75 * MercurySupConj returns the time of a superior conjunction of Mercury.
76 *
77 * Result is time (as a jde) of the event nearest the given time (as a
78 * decimal year.)
79 */
80export function mercurySupConj(y) {
81 // (y float64) (jde float64)
82 return ms(y, mscA, mscB);
83}
84
85/**
86 * VenusInfConj returns the time of an inferior conjunction of Venus.
87 *
88 * Result is time (as a jde) of the event nearest the given time (as a
89 * decimal year.)
90 */
91export function venusInfConj(y) {
92 // (y float64) (jde float64)
93 return ms(y, vicA, vicB);
94}
95
96/**
97 * MarsOpp returns the time of an opposition of Mars.
98 *
99 * Result is time (as a jde) of the event nearest the given time (as a
100 * decimal year.)
101 */
102export function marsOpp(y) {
103 // (y float64) (jde float64)
104 return ms(y, moA, moB);
105}
106
107/**
108 * SumA computes the sum of periodic terms with "additional angles"
109 */
110export function sumA(T, M, c, aa) {
111 // (T, M float64, c [][]float64, aa []caa) float64
112 var i = c.length - 2 * aa.length;
113 var j = sum(T, M, c.slice(0, i));
114 for (var k = 0; k < aa.length; k++) {
115 var _base$sincos2 = base.sincos((aa[k].c + aa[k].f * T) * Math.PI / 180),
116 _saa = _base$sincos2[0],
117 caa = _base$sincos2[1];
118
119 j += _saa * base.horner(T, c[i]);
120 i++;
121 j += caa * base.horner(T, c[i]);
122 i++;
123 }
124 return j;
125}
126
127/**
128 * Msa returns a mean time corrected by a sum.
129 */
130export function msa(y, a, c, aa) {
131 // (y float64, a *ca, c [][]float64, aa []caa) float64
132 var _mean2 = mean(y, a),
133 J = _mean2[0],
134 M = _mean2[1],
135 T = _mean2[2];
136
137 return J + sumA(T, M, c, aa);
138}
139
140/**
141 * JupiterOpp returns the time of an opposition of Jupiter.
142 *
143 * Result is time (as a jde) of the event nearest the given time (as a
144 * decimal year.)
145 */
146export function jupiterOpp(y) {
147 // (y float64) (jde float64)
148 return msa(y, joA, joB, jaa);
149}
150
151/**
152 * SaturnOpp returns the time of an opposition of Saturn.
153 *
154 * Result is time (as a jde) of the event nearest the given time (as a
155 * decimal year.)
156 */
157export function saturnOpp(y) {
158 // (y float64) (jde float64)
159 return msa(y, soA, soB, saa);
160}
161
162/**
163 * SaturnConj returns the time of a conjunction of Saturn.
164 *
165 * Result is time (as a jde) of the event nearest the given time (as a
166 * decimal year.)
167 */
168export function saturnConj(y) {
169 // (y float64) (jde float64)
170 return msa(y, scA, scB, saa);
171}
172
173/**
174 * UranusOpp returns the time of an opposition of Uranus.
175 *
176 * Result is time (as a jde) of the event nearest the given time (as a
177 * decimal year.)
178 */
179export function uranusOpp(y) {
180 // (y float64) (jde float64)
181 return msa(y, uoA, uoB, uaa);
182}
183
184/**
185 * NeptuneOpp returns the time of an opposition of Neptune.
186 *
187 * Result is time (as a jde) of the event nearest the given time (as a
188 * decimal year.)
189 */
190export function neptuneOpp(y) {
191 // (y float64) (jde float64)
192 return msa(y, noA, noB, naa);
193}
194
195/**
196 * El computes time and elongation of a greatest elongation event.
197 */
198export function el(y, a, t, e) {
199 // (y float64, a *ca, t, e [][]float64) (jde, elongation float64)
200 var _mean3 = mean(y, micA),
201 J = _mean3[0],
202 M = _mean3[1],
203 T = _mean3[2];
204
205 return [J + sum(T, M, t), sum(T, M, e) * Math.PI / 180];
206}
207
208/**
209 * MercuryEastElongation returns the time and elongation of a greatest eastern elongation of Mercury.
210 *
211 * Result is time (as a jde) of the event nearest the given time (as a
212 * decimal year.)
213 */
214export function mercuryEastElongation(y) {
215 // (y float64) (jde, elongation float64)
216 return el(y, micA, met, mee);
217}
218
219/**
220 * MercuryWestElongation returns the time and elongation of a greatest western elongation of Mercury.
221 *
222 * Result is time (as a jde) of the event nearest the given time (as a
223 * decimal year.)
224 */
225export function mercuryWestElongation(y) {
226 // (y float64) (jde, elongation float64)
227 return el(y, micA, mwt, mwe);
228}
229
230export function marsStation2(y) {
231 // (y float64) (jde float64)
232 var _mean4 = mean(y, moA),
233 J = _mean4[0],
234 M = _mean4[1],
235 T = _mean4[2];
236
237 return J + sum(T, M, ms2);
238}
239
240/**
241 * ca holds coefficients from one line of table 36.A, p. 250
242 */
243function Ca(A, B, M0, M1) {
244 this.A = A;
245 this.B = B;
246 this.M0 = M0;
247 this.M1 = M1;
248}
249
250/**
251 * Table 36.A, p. 250
252 */
253var micA = new Ca(2451612.023, 115.8774771, 63.5867, 114.2088742);
254var mscA = new Ca(2451554.084, 115.8774771, 6.4822, 114.2088742);
255var vicA = new Ca(2451996.706, 583.921361, 82.7311, 215.513058);
256var moA = new Ca(2452097.382, 779.936104, 181.9573, 48.705244);
257var joA = new Ca(2451870.628, 398.884046, 318.4681, 33.140229);
258var soA = new Ca(2451870.17, 378.091904, 318.0172, 12.647487);
259var scA = new Ca(2451681.124, 378.091904, 131.6934, 12.647487);
260var uoA = new Ca(2451764.317, 369.656035, 213.6884, 4.333093);
261var noA = new Ca(2451753.122, 367.486703, 202.6544, 2.194998);
262
263/**
264 * caa holds coefficients for "additional angles" for outer planets
265 * as given on p. 251
266 */
267function Caa(c, f) {
268 this.c = c;
269 this.f = f;
270}
271
272var jaa = [new Caa(82.74, 40.76)];
273
274var saa = [new Caa(82.74, 40.76), new Caa(29.86, 1181.36), new Caa(14.13, 590.68), new Caa(220.02, 1262.87)];
275
276var uaa = [new Caa(207.83, 8.51), new Caa(108.84, 419.96)];
277
278var naa = [new Caa(207.83, 8.51), new Caa(276.74, 209.98)];
279
280/**
281 * Table 33.B, p. 256
282 */
283
284/**
285 * Mercury inferior conjunction
286 */
287var micB = [[0.0545, 0.0002], [-6.2008, 0.0074, 0.00003], [-3.275, -0.0197, 0.00001], [0.4737, -0.0052, -0.00001], [0.8111, 0.0033, -0.00002], [0.0037, 0.0018], [-0.1768, 0, 0.00001], [-0.0211, -0.0004], [0.0326, -0.0003], [0.0083, 0.0001], [-0.004, 0.0001]];
288
289/**
290 * Mercury superior conjunction
291 */
292var mscB = [[-0.0548, -0.0002], [7.3894, -0.01, -0.00003], [3.22, 0.0197, -0.00001], [0.8383, -0.0064, -0.00001], [0.9666, 0.0039, -0.00003], [0.077, -0.0026], [0.2758, 0.0002, -0.00002], [-0.0128, -0.0008], [0.0734, -0.0004, -0.00001], [-0.0122, -0.0002], [0.0173, -0.0002]];
293
294/**
295 * Venus inferior conjunction
296 */
297var vicB = [[-0.0096, 0.0002, -0.00001], [2.0009, -0.0033, -0.00001], [0.598, -0.0104, 0.00001], [0.0967, -0.0018, -0.00003], [0.0913, 0.0009, -0.00002], [0.0046, -0.0002], [0.0079, 0.0001]];
298
299/**
300 * Mars opposition
301 */
302var moB = [[-0.3088, 0, 0.00002], [-17.6965, 0.0363, 0.00005], [18.3131, 0.0467, -0.00006], [-0.2162, -0.0198, -0.00001], [-4.5028, -0.0019, 0.00007], [0.8987, 0.0058, -0.00002], [0.7666, -0.005, -0.00003], [-0.3636, -0.0001, 0.00002], [0.0402, 0.0032], [0.0737, -0.0008], [-0.098, -0.0011]];
303
304/**
305 * Jupiter opposition
306 */
307var joB = [[-0.1029, 0, -0.00009], [-1.9658, -0.0056, 0.00007], [6.1537, 0.021, -0.00006], [-0.2081, -0.0013], [-0.1116, -0.001], [0.0074, 0.0001], [-0.0097, -0.0001], [0, 0.0144, -0.00008], [0.3642, -0.0019, -0.00029]];
308
309/**
310 * Saturn opposition
311 */
312var soB = [[-0.0209, 0.0006, 0.00023], [4.5795, -0.0312, -0.00017], [1.1462, -0.0351, 0.00011], [0.0985, -0.0015], [0.0733, -0.0031, 0.00001], [0.0025, -0.0001], [0.005, -0.0002], [0, -0.0337, 0.00018], [-0.851, 0.0044, 0.00068], [0, -0.0064, 0.00004], [0.2397, -0.0012, -0.00008], [0, -0.001], [0.1245, 0.0006], [0, 0.0024, -0.00003], [0.0477, -0.0005, -0.00006]];
313
314/**
315 * Saturn conjunction
316 */
317var scB = [[0.0172, -0.0006, 0.00023], [-8.5885, 0.0411, 0.00020], [-1.147, 0.0352, -0.00011], [0.3331, -0.0034, -0.00001], [0.1145, -0.0045, 0.00002], [-0.0169, 0.0002], [-0.0109, 0.0004], [0, -0.0337, 0.00018], [-0.851, 0.0044, 0.00068], [0, -0.0064, 0.00004], [0.2397, -0.0012, -0.00008], [0, -0.001], [0.1245, 0.0006], [0, 0.0024, -0.00003], [0.0477, -0.0005, -0.00006]];
318
319/**
320 * Uranus opposition
321 */
322var uoB = [[0.0844, -0.0006], [-0.1048, 0.0246], [-5.1221, 0.0104, 0.00003], [-0.1428, 0.0005], [-0.0148, -0.0013], [0], [0.0055], [0], [0.885], [0], [0.2153]];
323
324/**
325 * Neptune opposition [
326 */
327var noB = [[-0.014, 0, 0.00001], [-1.3486, 0.001, 0.00001], [0.8597, 0.0037], [-0.0082, -0.0002, 0.00001], [0.0037, -0.0003], [0], [-0.5964], [0], [0.0728]];
328
329/**
330 * Table 36.C, p. 259
331 */
332
333/**
334 * Mercury east time correction
335 */
336var met = [[-21.6106, 0.0002], [-1.9803, -0.006, 0.00001], [1.4151, -0.0072, -0.00001], [0.5528, -0.0005, -0.00001], [0.2905, 0.0034, 0.00001], [-0.1121, -0.0001, 0.00001], [-0.0098, -0.0015], [0.0192], [0.0111, 0.0004], [-0.0061], [-0.0032, -0.0001]];
337
338/**
339 * Mercury east elongation
340 */
341var mee = [[22.4697], [-4.2666, 0.0054, 0.00002], [-1.8537, -0.0137], [0.3598, 0.0008, -0.00001], [-0.068, 0.0026], [-0.0524, -0.0003], [0.0052, -0.0006], [0.0107, 0.0001], [-0.0013, 0.0001], [-0.0021], [0.0003]];
342
343/**
344 * Mercury west time correction
345 */
346var mwt = [[21.6249, -0.0002], [0.1306, 0.0065], [-2.7661, -0.0011, 0.00001], [0.2438, -0.0024, -0.00001], [0.5767, 0.0023], [0.1041], [-0.0184, 0.0007], [-0.0051, -0.0001], [0.0048, 0.0001], [0.0026], [0.0037]];
347
348/**
349 * Mercury west elongation
350 */
351var mwe = [[22.4143, -0.0001], [4.3651, -0.0048, -0.00002], [2.3787, 0.0121, -0.00001], [0.2674, 0.0022], [-0.3873, 0.0008, 0.00001], [-0.0369, -0.0001], [0.0017, -0.0001], [0.0059], [0.0061, 0.0001], [0.0007], [-0.0011]];
352
353/**
354 * Table 36.D, p. 261
355 */
356
357/**
358 * Mars Station 2
359 */
360var ms2 = [[36.7191, 0.0016, 0.00003], [-12.6163, 0.0417, -0.00001], [20.1218, 0.0379, -0.00006], [-1.636, -0.019], [-3.9657, 0.0045, 0.00007], [1.1546, 0.0029, -0.00003], [0.2888, -0.0073, -0.00002], [-0.3128, 0.0017, 0.00002], [0.2513, 0.0026, -0.00002], [-0.0021, -0.0016], [-0.1497, -0.0006]];
361
362export default {
363 mean: mean,
364 sum: sum,
365 ms: ms,
366 mercuryInfConj: mercuryInfConj,
367 mercurySupConj: mercurySupConj,
368 venusInfConj: venusInfConj,
369 marsOpp: marsOpp,
370 sumA: sumA,
371 msa: msa,
372 jupiterOpp: jupiterOpp,
373 saturnOpp: saturnOpp,
374 saturnConj: saturnConj,
375 uranusOpp: uranusOpp,
376 neptuneOpp: neptuneOpp,
377 el: el,
378 mercuryEastElongation: mercuryEastElongation,
379 mercuryWestElongation: mercuryWestElongation,
380 marsStation2: marsStation2
381};
\No newline at end of file