1 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | import base from './base';
|
14 |
|
15 | var ck = 1 / 1236.85;
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | export var meanLunarMonth = 29.530588861;
|
21 |
|
22 |
|
23 | function mean(T) {
|
24 | return base.horner(T, 2451550.09766, 29.530588861 / ck, 0.00015437, -0.00000015, 0.00000000073);
|
25 | }
|
26 |
|
27 |
|
28 | function snap(y, q) {
|
29 | var k = (y - 2000) * 12.3685;
|
30 | return Math.floor(k - q + 0.5) + q;
|
31 | }
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | export function meanNew(year) {
|
41 | return mean(snap(year, 0) * ck);
|
42 | }
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | export function meanFirst(year) {
|
52 | return mean(snap(year, 0.25) * ck);
|
53 | }
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 | export function meanFull(year) {
|
63 | return mean(snap(year, 0.5) * ck);
|
64 | }
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 | export function meanLast(year) {
|
74 | return mean(snap(year, 0.75) * ck);
|
75 | }
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 | export function newMoon(year) {
|
84 | var m = new Mp(year, 0);
|
85 | return mean(m.T) + m.nfc(nc) + m.a();
|
86 | }
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 | export function first(year, month, day) {
|
95 | var m = new Mp(year, 0.25);
|
96 | return mean(m.T) + m.flc() + m.w() + m.a();
|
97 | }
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 | export function full(year, month, day) {
|
106 | var m = new Mp(year, 0.5);
|
107 | return mean(m.T) + m.nfc(fc) + m.a();
|
108 | }
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 | export function last(year, month, day) {
|
117 | var m = new Mp(year, 0.75);
|
118 | return mean(m.T) + m.flc() - m.w() + m.a();
|
119 | }
|
120 |
|
121 | var p = Math.PI / 180;
|
122 |
|
123 | var Mp = function () {
|
124 | function Mp(y, q) {
|
125 | _classCallCheck(this, Mp);
|
126 |
|
127 | this.A = new Array(14);
|
128 | this.k = snap(y, q);
|
129 | this.T = this.k * ck;
|
130 | this.E = base.horner(this.T, 1, -0.002516, -0.0000074);
|
131 | this.M = base.horner(this.T, 2.5534 * p, 29.1053567 * p / ck, -0.0000014 * p, -0.00000011 * p);
|
132 | this.M_ = base.horner(this.T, 201.5643 * p, 385.81693528 * p / ck, 0.0107582 * p, 0.00001238 * p, -0.000000058 * p);
|
133 | this.F = base.horner(this.T, 160.7108 * p, 390.67050284 * p / ck, -0.0016118 * p, -0.00000227 * p, 0.000000011 * p);
|
134 | this.Ω = base.horner(this.T, 124.7746 * p, -1.56375588 * p / ck, 0.0020672 * p, 0.00000215 * p);
|
135 | this.A[0] = 299.7 * p + 0.107408 * p * this.k - 0.009173 * this.T * this.T;
|
136 | this.A[1] = 251.88 * p + 0.016321 * p * this.k;
|
137 | this.A[2] = 251.83 * p + 26.651886 * p * this.k;
|
138 | this.A[3] = 349.42 * p + 36.412478 * p * this.k;
|
139 | this.A[4] = 84.66 * p + 18.206239 * p * this.k;
|
140 | this.A[5] = 141.74 * p + 53.303771 * p * this.k;
|
141 | this.A[6] = 207.17 * p + 2.453732 * p * this.k;
|
142 | this.A[7] = 154.84 * p + 7.30686 * p * this.k;
|
143 | this.A[8] = 34.52 * p + 27.261239 * p * this.k;
|
144 | this.A[9] = 207.19 * p + 0.121824 * p * this.k;
|
145 | this.A[10] = 291.34 * p + 1.844379 * p * this.k;
|
146 | this.A[11] = 161.72 * p + 24.198154 * p * this.k;
|
147 | this.A[12] = 239.56 * p + 25.513099 * p * this.k;
|
148 | this.A[13] = 331.55 * p + 3.592518 * p * this.k;
|
149 | }
|
150 |
|
151 |
|
152 |
|
153 |
|
154 | Mp.prototype.nfc = function nfc(c) {
|
155 | return c[0] * Math.sin(this.M_) + c[1] * Math.sin(this.M) * this.E + c[2] * Math.sin(2 * this.M_) + c[3] * Math.sin(2 * this.F) + c[4] * Math.sin(this.M_ - this.M) * this.E + c[5] * Math.sin(this.M_ + this.M) * this.E + c[6] * Math.sin(2 * this.M) * this.E * this.E + c[7] * Math.sin(this.M_ - 2 * this.F) + c[8] * Math.sin(this.M_ + 2 * this.F) + c[9] * Math.sin(2 * this.M_ + this.M) * this.E + c[10] * Math.sin(3 * this.M_) + c[11] * Math.sin(this.M + 2 * this.F) * this.E + c[12] * Math.sin(this.M - 2 * this.F) * this.E + c[13] * Math.sin(2 * this.M_ - this.M) * this.E + c[14] * Math.sin(this.Ω) + c[15] * Math.sin(this.M_ + 2 * this.M) + c[16] * Math.sin(2 * (this.M_ - this.F)) + c[17] * Math.sin(3 * this.M) + c[18] * Math.sin(this.M_ + this.M - 2 * this.F) + c[19] * Math.sin(2 * (this.M_ + this.F)) + c[20] * Math.sin(this.M_ + this.M + 2 * this.F) + c[21] * Math.sin(this.M_ - this.M + 2 * this.F) + c[22] * Math.sin(this.M_ - this.M - 2 * this.F) + c[23] * Math.sin(3 * this.M_ + this.M) + c[24] * Math.sin(4 * this.M_);
|
156 | };
|
157 |
|
158 |
|
159 |
|
160 |
|
161 | Mp.prototype.flc = function flc() {
|
162 | return -0.62801 * Math.sin(this.M_) + 0.17172 * Math.sin(this.M) * this.E + -0.01183 * Math.sin(this.M_ + this.M) * this.E + 0.00862 * Math.sin(2 * this.M_) + 0.00804 * Math.sin(2 * this.F) + 0.00454 * Math.sin(this.M_ - this.M) * this.E + 0.00204 * Math.sin(2 * this.M) * this.E * this.E + -0.0018 * Math.sin(this.M_ - 2 * this.F) + -0.0007 * Math.sin(this.M_ + 2 * this.F) + -0.0004 * Math.sin(3 * this.M_) + -0.00034 * Math.sin(2 * this.M_ - this.M) + 0.00032 * Math.sin(this.M + 2 * this.F) * this.E + 0.00032 * Math.sin(this.M - 2 * this.F) * this.E + -0.00028 * Math.sin(this.M_ + 2 * this.M) * this.E * this.E + 0.00027 * Math.sin(2 * this.M_ + this.M) * this.E + -0.00017 * Math.sin(this.Ω) + -0.00005 * Math.sin(this.M_ - this.M - 2 * this.F) + 0.00004 * Math.sin(2 * this.M_ + 2 * this.F) + -0.00004 * Math.sin(this.M_ + this.M + 2 * this.F) + 0.00004 * Math.sin(this.M_ - 2 * this.M) + 0.00003 * Math.sin(this.M_ + this.M - 2 * this.F) + 0.00003 * Math.sin(3 * this.M) + 0.00002 * Math.sin(2 * this.M_ - 2 * this.F) + 0.00002 * Math.sin(this.M_ - this.M + 2 * this.F) + -0.00002 * Math.sin(3 * this.M_ + this.M);
|
163 | };
|
164 |
|
165 | Mp.prototype.w = function w() {
|
166 | return 0.00306 - 0.00038 * this.E * Math.cos(this.M) + 0.00026 * Math.cos(this.M_) - 0.00002 * (Math.cos(this.M_ - this.M) - Math.cos(this.M_ + this.M) - Math.cos(2 * this.F));
|
167 | };
|
168 |
|
169 |
|
170 |
|
171 |
|
172 | Mp.prototype.a = function a() {
|
173 | var _this = this;
|
174 |
|
175 | var a = 0;
|
176 | ac.forEach(function (c, i) {
|
177 | a += c * Math.sin(_this.A[i]);
|
178 | });
|
179 | return a;
|
180 | };
|
181 |
|
182 | return Mp;
|
183 | }();
|
184 |
|
185 |
|
186 |
|
187 |
|
188 | var nc = [-0.4072, 0.17241, 0.01608, 0.01039, 0.00739, -0.00514, 0.00208, -0.00111, -0.00057, 0.00056, -0.00042, 0.00042, 0.00038, -0.00024, -0.00017, -0.00007, 0.00004, 0.00004, 0.00003, 0.00003, -0.00003, 0.00003, -0.00002, -0.00002, 0.00002];
|
189 |
|
190 |
|
191 | var fc = [-0.40614, 0.17302, 0.01614, 0.01043, 0.00734, -0.00515, 0.00209, -0.00111, -0.00057, 0.00056, -0.00042, 0.00042, 0.00038, -0.00024, -0.00017, -0.00007, 0.00004, 0.00004, 0.00003, 0.00003, -0.00003, 0.00003, -0.00002, -0.00002, 0.00002];
|
192 |
|
193 |
|
194 | var ac = [0.000325, 0.000165, 0.000164, 0.000126, 0.00011, 0.000062, 0.00006, 0.000056, 0.000047, 0.000042, 0.000040, 0.000037, 0.000035, 0.000023];
|
195 |
|
196 | export default {
|
197 | meanLunarMonth: meanLunarMonth,
|
198 | meanNew: meanNew,
|
199 | meanFirst: meanFirst,
|
200 | meanFull: meanFull,
|
201 | meanLast: meanLast,
|
202 | newMoon: newMoon,
|
203 | new: newMoon,
|
204 | first: first,
|
205 | full: full,
|
206 | last: last
|
207 | }; |
\ | No newline at end of file |