1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.Elements = undefined;
|
7 |
|
8 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
9 |
|
10 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
11 |
|
12 | var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); |
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | exports.position = position;
|
27 | exports.astrometricJ2000 = astrometricJ2000;
|
28 | exports.velocity = velocity;
|
29 | exports.vAphelion = vAphelion;
|
30 | exports.vPerihelion = vPerihelion;
|
31 | exports.length1 = length1;
|
32 | exports.length2 = length2;
|
33 | exports.length4 = length4;
|
34 |
|
35 | var _apparent = require('./apparent');
|
36 |
|
37 | var _apparent2 = _interopRequireDefault(_apparent);
|
38 |
|
39 | var _base = require('./base');
|
40 |
|
41 | var _base2 = _interopRequireDefault(_base);
|
42 |
|
43 | var _coord = require('./coord');
|
44 |
|
45 | var _coord2 = _interopRequireDefault(_coord);
|
46 |
|
47 | var _kepler = require('./kepler');
|
48 |
|
49 | var _kepler2 = _interopRequireDefault(_kepler);
|
50 |
|
51 | var _nutation = require('./nutation');
|
52 |
|
53 | var _nutation2 = _interopRequireDefault(_nutation);
|
54 |
|
55 | var _planetposition = require('./planetposition');
|
56 |
|
57 | var _planetposition2 = _interopRequireDefault(_planetposition);
|
58 |
|
59 | var _solarxyz = require('./solarxyz');
|
60 |
|
61 | var _solarxyz2 = _interopRequireDefault(_solarxyz);
|
62 |
|
63 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
64 |
|
65 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 | function position(planet, earth, jde) {
|
76 |
|
77 | var x = void 0;
|
78 | var y = void 0;
|
79 | var z = void 0;
|
80 | var posEarth = earth.position(jde);
|
81 | var _ref = [posEarth.lon, posEarth.lat, posEarth.range],
|
82 | L0 = _ref[0],
|
83 | B0 = _ref[1],
|
84 | R0 = _ref[2];
|
85 |
|
86 | var _base$sincos = _base2.default.sincos(B0),
|
87 | _base$sincos2 = _slicedToArray(_base$sincos, 2),
|
88 | sB0 = _base$sincos2[0],
|
89 | cB0 = _base$sincos2[1];
|
90 |
|
91 | var _base$sincos3 = _base2.default.sincos(L0),
|
92 | _base$sincos4 = _slicedToArray(_base$sincos3, 2),
|
93 | sL0 = _base$sincos4[0],
|
94 | cL0 = _base$sincos4[1];
|
95 |
|
96 | function pos() {
|
97 | var τ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
98 |
|
99 | var pos = planet.position(jde - τ);
|
100 | var _ref2 = [pos.lon, pos.lat, pos.range],
|
101 | L = _ref2[0],
|
102 | B = _ref2[1],
|
103 | R = _ref2[2];
|
104 |
|
105 | var _base$sincos5 = _base2.default.sincos(B),
|
106 | _base$sincos6 = _slicedToArray(_base$sincos5, 2),
|
107 | sB = _base$sincos6[0],
|
108 | cB = _base$sincos6[1];
|
109 |
|
110 | var _base$sincos7 = _base2.default.sincos(L),
|
111 | _base$sincos8 = _slicedToArray(_base$sincos7, 2),
|
112 | sL = _base$sincos8[0],
|
113 | cL = _base$sincos8[1];
|
114 |
|
115 | x = R * cB * cL - R0 * cB0 * cL0;
|
116 | y = R * cB * sL - R0 * cB0 * sL0;
|
117 | z = R * sB - R0 * sB0;
|
118 | }
|
119 |
|
120 | pos();
|
121 | var Δ = Math.sqrt(x * x + y * y + z * z);
|
122 | var τ = _base2.default.lightTime(Δ);
|
123 |
|
124 | pos(τ);
|
125 |
|
126 | var λ = Math.atan2(y, x);
|
127 | var β = Math.atan2(z, Math.hypot(x, y));
|
128 |
|
129 | var _apparent$eclipticAbe = _apparent2.default.eclipticAberration(λ, β, jde),
|
130 | _apparent$eclipticAbe2 = _slicedToArray(_apparent$eclipticAbe, 2),
|
131 | Δλ = _apparent$eclipticAbe2[0],
|
132 | Δβ = _apparent$eclipticAbe2[1];
|
133 |
|
134 | var fk5 = _planetposition2.default.toFK5(λ + Δλ, β + Δβ, jde);
|
135 | λ = fk5.lon;
|
136 | β = fk5.lat;
|
137 |
|
138 | var _nutation$nutation = _nutation2.default.nutation(jde),
|
139 | _nutation$nutation2 = _slicedToArray(_nutation$nutation, 2),
|
140 | Δψ = _nutation$nutation2[0],
|
141 | Δε = _nutation$nutation2[1];
|
142 |
|
143 | λ += Δψ;
|
144 | var ε = _nutation2.default.meanObliquity(jde) + Δε;
|
145 | return new _coord2.default.Ecliptic(λ, β).toEquatorial(ε);
|
146 |
|
147 |
|
148 | }
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 | var Elements = exports.Elements = function () {
|
155 | |
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 | function Elements(axis, ecc, inc, argP, node, timeP) {
|
164 | _classCallCheck(this, Elements);
|
165 |
|
166 | var o = {};
|
167 | if ((typeof axis === 'undefined' ? 'undefined' : _typeof(axis)) === 'object') {
|
168 | o = axis;
|
169 | }
|
170 | this.axis = o.axis || axis;
|
171 | this.ecc = o.ecc || ecc;
|
172 | this.inc = o.inc || inc;
|
173 | this.argP = o.argP || argP;
|
174 | this.node = o.node || node;
|
175 | this.timeP = o.timeP || timeP;
|
176 | }
|
177 |
|
178 | |
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 | _createClass(Elements, [{
|
189 | key: 'position',
|
190 | value: function position(jde, earth) {
|
191 | var _this = this;
|
192 |
|
193 |
|
194 |
|
195 | var n = _base2.default.K / this.axis / Math.sqrt(this.axis);
|
196 | var sε = _base2.default.SOblJ2000;
|
197 | var cε = _base2.default.COblJ2000;
|
198 |
|
199 | var _base$sincos9 = _base2.default.sincos(this.node),
|
200 | _base$sincos10 = _slicedToArray(_base$sincos9, 2),
|
201 | sΩ = _base$sincos10[0],
|
202 | cΩ = _base$sincos10[1];
|
203 |
|
204 | var _base$sincos11 = _base2.default.sincos(this.inc),
|
205 | _base$sincos12 = _slicedToArray(_base$sincos11, 2),
|
206 | si = _base$sincos12[0],
|
207 | ci = _base$sincos12[1];
|
208 |
|
209 |
|
210 |
|
211 | var F = cΩ;
|
212 | var G = sΩ * cε;
|
213 | var H = sΩ * sε;
|
214 | var P = -sΩ * ci;
|
215 | var Q = cΩ * ci * cε - si * sε;
|
216 | var R = cΩ * ci * sε + si * cε;
|
217 |
|
218 | var A = Math.atan2(F, P);
|
219 | var B = Math.atan2(G, Q);
|
220 | var C = Math.atan2(H, R);
|
221 | var a = Math.hypot(F, P);
|
222 | var b = Math.hypot(G, Q);
|
223 | var c = Math.hypot(H, R);
|
224 |
|
225 | var f = function f(jde) {
|
226 |
|
227 | var M = n * (jde - _this.timeP);
|
228 | var E = void 0;
|
229 | try {
|
230 | E = _kepler2.default.kepler2b(_this.ecc, M, 15);
|
231 | } catch (e) {
|
232 | E = _kepler2.default.kepler3(_this.ecc, M);
|
233 | }
|
234 | var ν = _kepler2.default.trueAnomaly(E, _this.ecc);
|
235 | var r = _kepler2.default.radius(E, _this.ecc, _this.axis);
|
236 |
|
237 | var x = r * a * Math.sin(A + _this.argP + ν);
|
238 | var y = r * b * Math.sin(B + _this.argP + ν);
|
239 | var z = r * c * Math.sin(C + _this.argP + ν);
|
240 | return { x: x, y: y, z: z };
|
241 | };
|
242 | return astrometricJ2000(f, jde, earth);
|
243 | }
|
244 | }]);
|
245 |
|
246 | return Elements;
|
247 | }();
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 | function astrometricJ2000(f, jde, earth) {
|
263 |
|
264 | var sol = _solarxyz2.default.positionJ2000(earth, jde);
|
265 | var _ref3 = [sol.x, sol.y, sol.z],
|
266 | X = _ref3[0],
|
267 | Y = _ref3[1],
|
268 | Z = _ref3[2];
|
269 |
|
270 | var ξ = void 0;
|
271 | var η = void 0;
|
272 | var ζ = void 0;
|
273 | var Δ = void 0;
|
274 |
|
275 | function fn() {
|
276 | var τ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
277 |
|
278 |
|
279 | var _f = f(jde - τ),
|
280 | x = _f.x,
|
281 | y = _f.y,
|
282 | z = _f.z;
|
283 |
|
284 | ξ = X + x;
|
285 | η = Y + y;
|
286 | ζ = Z + z;
|
287 | Δ = Math.sqrt(ξ * ξ + η * η + ζ * ζ);
|
288 | }
|
289 |
|
290 | fn();
|
291 | var τ = _base2.default.lightTime(Δ);
|
292 | fn(τ);
|
293 |
|
294 | var α = Math.atan2(η, ξ);
|
295 | if (α < 0) {
|
296 | α += 2 * Math.PI;
|
297 | }
|
298 | var δ = Math.asin(ζ / Δ);
|
299 | var R0 = Math.sqrt(X * X + Y * Y + Z * Z);
|
300 | var ψ = Math.acos((ξ * X + η * Y + ζ * Z) / R0 / Δ);
|
301 | return new _base2.default.Coord(α, δ, undefined, ψ);
|
302 | }
|
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 | function velocity(a, r) {
|
313 |
|
314 | return 42.1219 * Math.sqrt(1 / r - 0.5 / a);
|
315 | }
|
316 |
|
317 |
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 | function vAphelion(a, e) {
|
325 |
|
326 | return 29.7847 * Math.sqrt((1 - e) / (1 + e) / a);
|
327 | }
|
328 |
|
329 |
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 | function vPerihelion(a, e) {
|
337 |
|
338 | return 29.7847 * Math.sqrt((1 + e) / (1 - e) / a);
|
339 | }
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 | function length1(a, e) {
|
350 |
|
351 | var b = a * Math.sqrt(1 - e * e);
|
352 | return Math.PI * (3 * (a + b) - Math.sqrt((a + 3 * b) * (3 * a + b)));
|
353 | }
|
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 | function length2(a, e) {
|
364 |
|
365 | var b = a * Math.sqrt(1 - e * e);
|
366 | var s = a + b;
|
367 | var p = a * b;
|
368 | var A = s * 0.5;
|
369 | var G = Math.sqrt(p);
|
370 | var H = 2 * p / s;
|
371 | return Math.PI * (21 * A - 2 * G - 3 * H) * 0.125;
|
372 | }
|
373 |
|
374 |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 |
|
407 |
|
408 | function length4(a, e) {
|
409 |
|
410 | var b = a * Math.sqrt(1 - e * e);
|
411 | var m = (a - b) / (a + b);
|
412 | var m2 = m * m;
|
413 | var sum0 = 1.0;
|
414 | var term = m2 * 0.25;
|
415 | var sum1 = 1.0 + term;
|
416 | var nf = -1.0;
|
417 | var df = 2.0;
|
418 | while (sum1 !== sum0) {
|
419 | nf += 2;
|
420 | df += 2;
|
421 | term *= nf * nf * m2 / (df * df);
|
422 | sum0 = sum1;
|
423 | sum1 += term;
|
424 | }
|
425 | return 2 * Math.PI * a * sum0 / (1 + m);
|
426 | }
|
427 |
|
428 | exports.default = {
|
429 | position: position,
|
430 | Elements: Elements,
|
431 | astrometricJ2000: astrometricJ2000,
|
432 | velocity: velocity,
|
433 | vAphelion: vAphelion,
|
434 | vPerihelion: vPerihelion,
|
435 | length1: length1,
|
436 | length2: length2,
|
437 |
|
438 | length4: length4
|
439 | }; |
\ | No newline at end of file |