UNPKG

7.46 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _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"); } }; }(); /**
8 * @copyright 2013 Sonia Keys
9 * @copyright 2016 commenthol
10 * @license MIT
11 * @module node
12 */
13/**
14 * Node: Chapter 39, Passages through the Nodes.
15 */
16
17exports.ellipticAscending = ellipticAscending;
18exports.ellipticDescending = ellipticDescending;
19exports.el = el;
20exports.parabolicAscending = parabolicAscending;
21exports.parabolicDescending = parabolicDescending;
22exports.pa = pa;
23
24var _base = require('./base');
25
26var _base2 = _interopRequireDefault(_base);
27
28function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
30/**
31 * EllipticAscending computes time and distance of passage through the ascending node of a body in an elliptical orbit.
32 *
33 * Argument axis is semimajor axis in AU, ecc is eccentricity, argP is argument
34 * of perihelion in radians, timeP is time of perihelion as a jd.
35 *
36 * Result is jde of the event and distance from the sun in AU.
37 */
38function ellipticAscending(axis, ecc, argP, timeP) {
39 // (axis, ecc, argP, timeP float64) (jde, r float64)
40 return el(-argP, axis, ecc, timeP);
41}
42
43/**
44 * EllipticAscending computes time and distance of passage through the descending node of a body in an elliptical orbit.
45 *
46 * Argument axis is semimajor axis in AU, ecc is eccentricity, argP is argument
47 * of perihelion in radians, timeP is time of perihelion as a jd.
48 *
49 * Result is jde of the event and distance from the sun in AU.
50 */
51function ellipticDescending(axis, ecc, argP, timeP) {
52 // (axis, ecc, argP, timeP float64) (jde, r float64)
53 return el(Math.PI - argP, axis, ecc, timeP);
54}
55
56function el(ν, axis, ecc, timeP) {
57 // (ν, axis, ecc, timeP float64) (jde, r float64)
58 var E = 2 * Math.atan(Math.sqrt((1 - ecc) / (1 + ecc)) * Math.tan(ν * 0.5));
59
60 var _base$sincos = _base2.default.sincos(E),
61 _base$sincos2 = _slicedToArray(_base$sincos, 2),
62 sE = _base$sincos2[0],
63 cE = _base$sincos2[1];
64
65 var M = E - ecc * sE;
66 var n = _base2.default.K / axis / Math.sqrt(axis);
67 var jde = timeP + M / n;
68 var r = axis * (1 - ecc * cE);
69 return [jde, r];
70}
71
72/**
73 * ParabolicAscending computes time and distance of passage through the ascending node of a body in a parabolic orbit.
74 *
75 * Argument q is perihelion distance in AU, argP is argument of perihelion
76 * in radians, timeP is time of perihelion as a jd.
77 *
78 * Result is jde of the event and distance from the sun in AU.
79 */
80function parabolicAscending(q, argP, timeP) {
81 // (q, argP, timeP float64) (jde, r float64)
82 return pa(-argP, q, timeP);
83}
84
85/**
86 * ParabolicDescending computes time and distance of passage through the descending node of a body in a parabolic orbit.
87 *
88 * Argument q is perihelion distance in AU, argP is argument of perihelion
89 * in radians, timeP is time of perihelion as a jd.
90 *
91 * Result is jde of the event and distance from the sun in AU.
92 */
93function parabolicDescending(q, argP, timeP) {
94 // (q, argP, timeP float64) (jde, r float64)
95 return pa(Math.PI - argP, q, timeP);
96}
97
98function pa(ν, q, timeP) {
99 // (ν, q, timeP float64) (jde, r float64)
100 var s = Math.tan(ν * 0.5);
101 var jde = timeP + 27.403895 * s * (s * s + 3) * q * Math.sqrt(q);
102 var r = q * (1 + s * s);
103 return [jde, r];
104}
105
106exports.default = {
107 ellipticAscending: ellipticAscending,
108 ellipticDescending: ellipticDescending,
109 el: el,
110 parabolicAscending: parabolicAscending,
111 parabolicDescending: parabolicDescending,
112 pa: pa
113};
\No newline at end of file