1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | 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"); } }; }(); /**
|
8 | * @copyright 2013 Sonia Keys
|
9 | * @copyright 2016 commenthol
|
10 | * @license MIT
|
11 | * @module binary
|
12 | */
|
13 | /**
|
14 | * Binary: Chapter 57, Binary Stars
|
15 | */
|
16 |
|
17 |
|
18 | exports.meanAnomaly = meanAnomaly;
|
19 | exports.position = position;
|
20 | exports.apparentEccentricity = apparentEccentricity;
|
21 |
|
22 | var _base = require('./base');
|
23 |
|
24 | var _base2 = _interopRequireDefault(_base);
|
25 |
|
26 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
27 |
|
28 | var atan = Math.atan,
|
29 | atan2 = Math.atan2,
|
30 | cos = Math.cos,
|
31 | sqrt = Math.sqrt,
|
32 | tan = Math.tan;
|
33 |
|
34 | /**
|
35 | * computes mean anomaly for the given date.
|
36 | *
|
37 | * @param {Number} year - is a decimal year specifying the date
|
38 | * @param {Number} T - is time of periastron, as a decimal year
|
39 | * @param {Number} P - is period of revolution in mean solar years
|
40 | * @returns {Number} mean anomaly in radians.
|
41 | */
|
42 |
|
43 | function meanAnomaly(year, T, P) {
|
44 | // (year, T, P float64) float64
|
45 | var n = 2 * Math.PI / P;
|
46 | return _base2.default.pmod(n * (year - T), 2 * Math.PI);
|
47 | }
|
48 |
|
49 | /**
|
50 | * Position computes apparent position angle and angular distance of
|
51 | * components of a binary star.
|
52 | *
|
53 | * @param {Number} a - is apparent semimajor axis in arc seconds
|
54 | * @param {Number} e - is eccentricity of the true orbit
|
55 | * @param {Number} i - is inclination relative to the line of sight
|
56 | * @param {Number} Ω - is position angle of the ascending node
|
57 | * @param {Number} ω - is longitude of periastron
|
58 | * @param {Number} E - is eccentric anomaly, computed for example with package kepler
|
59 | * and the mean anomaly as returned by function M in this package.
|
60 | * @returns {Number[]} [θ, ρ]
|
61 | * {Number} θ -is the apparent position angle in radians,
|
62 | * {Number} ρ is the angular distance in arc seconds.
|
63 | */
|
64 | function position(a, e, i, Ω, ω, E) {
|
65 | // (a, e, i, Ω, ω, E float64) (θ, ρ float64)
|
66 | var r = a * (1 - e * cos(E));
|
67 | var ν = 2 * atan(sqrt((1 + e) / (1 - e)) * tan(E / 2));
|
68 |
|
69 | var _base$sincos = _base2.default.sincos(ν + ω),
|
70 | _base$sincos2 = _slicedToArray(_base$sincos, 2),
|
71 | sinνω = _base$sincos2[0],
|
72 | cosνω = _base$sincos2[1];
|
73 |
|
74 | var cosi = cos(i);
|
75 | var num = sinνω * cosi;
|
76 | var θ = atan2(num, cosνω) + Ω;
|
77 | if (θ < 0) {
|
78 | θ += 2 * Math.PI;
|
79 | }
|
80 | var ρ = r * sqrt(num * num + cosνω * cosνω);
|
81 | return [θ, ρ];
|
82 | }
|
83 |
|
84 | /**
|
85 | * ApparentEccentricity returns apparent eccenticity of a binary star
|
86 | * given true orbital elements.
|
87 | *
|
88 | * @param {Number} e - is eccentricity of the true orbit
|
89 | * @param {Number} i - is inclination relative to the line of sight
|
90 | * @param {Number} ω - is longitude of periastron
|
91 | * @returns {Number} apparent eccenticity of a binary star
|
92 | */
|
93 | function apparentEccentricity(e, i, ω) {
|
94 | // (e, i, ω float64) float64
|
95 | var cosi = cos(i);
|
96 |
|
97 | var _base$sincos3 = _base2.default.sincos(ω),
|
98 | _base$sincos4 = _slicedToArray(_base$sincos3, 2),
|
99 | sinω = _base$sincos4[0],
|
100 | cosω = _base$sincos4[1];
|
101 |
|
102 | var A = (1 - e * e * cosω * cosω) * cosi * cosi;
|
103 | var B = e * e * sinω * cosω * cosi;
|
104 | var C = 1 - e * e * sinω * sinω;
|
105 | var d = A - C;
|
106 | var sqrtD = sqrt(d * d + 4 * B * B);
|
107 | return sqrt(2 * sqrtD / (A + C + sqrtD));
|
108 | }
|
109 |
|
110 | exports.default = {
|
111 | meanAnomaly: meanAnomaly,
|
112 | position: position,
|
113 | apparentEccentricity: apparentEccentricity
|
114 | }; |
\ | No newline at end of file |