UNPKG

8.21 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.neptune = exports.uranus = exports.saturn = exports.jupiter = exports.mars = exports.earth = exports.venus = exports.mercury = undefined;
7
8var _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 * @copyright 2013 Sonia Keys
10 * @copyright 2016 commenthol
11 * @license MIT
12 * @module planetelements
13 */
14/**
15 * Planetelements: Chapter 31, Elements of Planetary Orbits.
16 *
17 * Partial: Only implemented for mean equinox of date.
18 */
19
20exports.Elements = Elements;
21exports.mean = mean;
22exports.inc = inc;
23exports.node = node;
24
25var _base = require('./base');
26
27var _base2 = _interopRequireDefault(_base);
28
29function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30
31// planet names used in cMean
32var mercury = exports.mercury = 'mercury';
33var venus = exports.venus = 'venus';
34var earth = exports.earth = 'earth';
35var mars = exports.mars = 'mars';
36var jupiter = exports.jupiter = 'jupiter';
37var saturn = exports.saturn = 'saturn';
38var uranus = exports.uranus = 'uranus';
39var neptune = exports.neptune = 'neptune';
40
41/**
42 * Elements contains orbital elements as returned by functions in this package.
43 *
44 * Some other elements easily derived from these are
45 *
46 * Mean Anomolay, M = Lon - Peri
47 * Argument of Perihelion, ω = Peri - Node
48 *
49 * @param {Number} lon - mean longitude, L
50 * @param {Number} axis - semimajor axis, a
51 * @param {Number} ecc - eccentricity, e
52 * @param {Number} inc - inclination, i
53 * @param {Number} node - longitude of ascending node, Ω
54 * @param {Number} peri - longitude of perihelion, ϖ (Meeus likes π better)
55 */
56function Elements(lon, axis, ecc, inc, node, peri) {
57 var o = (typeof lon === 'undefined' ? 'undefined' : _typeof(lon)) === 'object' ? lon : {};
58 this.lon = o.lon || lon;
59 this.axis = o.axis || axis;
60 this.ecc = o.ecc || ecc;
61 this.inc = o.inc || inc;
62 this.node = o.node || node;
63 this.peri = o.peri || peri;
64}
65
66/**
67 * Table 31.A, p. 212
68 */
69var cMean = {
70 mercury: { // Mercury
71 L: [252.250906, 149474.0722491, 0.0003035, 0.000000018],
72 a: [0.38709831],
73 e: [0.20563175, 0.000020407, -0.0000000283, -0.00000000018],
74 i: [7.004986, 0.0018215, -0.0000181, 0.000000056],
75 Ω: [48.330893, 1.1861883, 0.00017542, 0.000000215],
76 ϖ: [77.456119, 1.5564776, 0.00029544, 0.000000009]
77 },
78 venus: { // Venus
79 L: [181.979801, 58519.2130302, 0.00031014, 0.000000015],
80 a: [0.72332982],
81 e: [0.00677192, -0.000047765, 0.0000000981, 0.00000000046],
82 i: [3.394662, 0.0010037, -0.00000088, -0.000000007],
83 Ω: [76.67992, 0.9011206, 0.00040618, -0.000000093],
84 ϖ: [131.563703, 1.4022288, -0.00107618, -0.000005678]
85 },
86 earth: { // Earth
87 L: [100.466457, 36000.7698278, 0.00030322, 0.00000002],
88 a: [1.000001018],
89 e: [0.01670863, -0.000042037, -0.0000001267, 0.00000000014],
90 i: [0],
91 Ω: undefined,
92 ϖ: [102.937348, 1.7195366, 0.00045688, -0.000000018]
93 },
94 mars: { // Mars
95 L: [355.433, 19141.6964471, 0.00031052, 0.000000016],
96 a: [1.523679342],
97 e: [0.09340065, 0.000090484, -0.0000000806, -0.00000000025],
98 i: [1.849726, -0.0006011, 0.00001276, -0.000000007],
99 Ω: [49.558093, 0.7720959, 0.00001557, 0.000002267],
100 ϖ: [336.060234, 1.8410449, 0.00013477, 0.000000536]
101 },
102 jupiter: { // Jupiter
103 L: [34.351519, 3036.3027748, 0.0002233, 0.000000037],
104 a: [5.202603209, 0.0000001913],
105 e: [0.04849793, 0.000163225, -0.0000004714, -0.00000000201],
106 i: [1.303267, -0.0054965, 0.00000466, -0.000000002],
107 Ω: [100.464407, 1.0209774, 0.00040315, 0.000000404],
108 ϖ: [14.331207, 1.6126352, 0.00103042, -0.000004464]
109 },
110 saturn: { // Saturn
111 L: [50.077444, 1223.5110686, 0.00051908, -0.00000003],
112 a: [9.554909192, -0.0000021390, 0.000000004],
113 e: [0.05554814, -0.000346641, -0.0000006436, 0.0000000034],
114 i: [2.488879, -0.0037362, -0.00001519, 0.000000087],
115 Ω: [113.665503, 0.877088, -0.00012176, -0.000002249],
116 ϖ: [93.057237, 1.9637613, 0.00083753, 0.000004928]
117 },
118 uranus: { // Uranus
119 L: [314.055005, 429.8640561, 0.0003039, 0.000000026],
120 a: [19.218446062, -0.0000000372, 0.00000000098],
121 e: [0.04638122, -0.000027293, 0.0000000789, 0.00000000024],
122 i: [0.773197, 0.0007744, 0.00003749, -0.000000092],
123 Ω: [74.005957, 0.5211278, 0.00133947, 0.000018484],
124 ϖ: [173.005291, 1.486379, 0.00021406, 0.000000434]
125 },
126 neptune: { // Neptune
127 L: [304.348665, 219.8833092, 0.00030882, 0.000000018],
128 a: [30.110386869, -0.0000001663, 0.00000000069],
129 e: [0.00945575, 0.000006033, 0, -0.00000000005],
130 i: [1.769953, -0.0093082, -0.00000708, 0.000000027],
131 Ω: [131.784057, 1.1022039, 0.00025952, -0.000000637],
132 ϖ: [48.120276, 1.4262957, 0.00038434, 0.00000002]
133 }
134
135 /**
136 * Mean returns mean orbital elements for a planet
137 *
138 * Argument p must be a planet const as defined above, argument e is
139 * a result parameter. A valid non-undefined pointer to an Elements struct
140 * must be passed in.
141 *
142 * Results are referenced to mean dynamical ecliptic and equinox of date.
143 *
144 * Semimajor axis is in AU, angular elements are in radians.
145 */
146};function mean(p, jde, e) {
147 var T = _base2.default.J2000Century(jde);
148 var c = cMean[p];
149 e = e || new Elements();
150 e.lon = _base2.default.pmod(_base2.default.horner(T, c.L) * Math.PI / 180, 2 * Math.PI);
151 e.axis = _base2.default.horner(T, c.a);
152 e.ecc = _base2.default.horner(T, c.e);
153 e.inc = _base2.default.horner(T, c.i) * Math.PI / 180;
154 e.node = _base2.default.horner(T, c.Ω) * Math.PI / 180;
155 e.peri = _base2.default.horner(T, c.ϖ) * Math.PI / 180;
156 return e;
157}
158
159/**
160 * Inc returns mean inclination for a planet at a date.
161 *
162 * Result is the same as the Inc field returned by function Mean. That is,
163 * radians, referenced to mean dynamical ecliptic and equinox of date.
164 */
165function inc(p, jde) {
166 // (p int, jde float64) float64
167 return _base2.default.horner(_base2.default.J2000Century(jde), cMean[p].i) * Math.PI / 180;
168}
169
170/**
171 * Node returns mean longitude of ascending node for a planet at a date.
172 *
173 * Result is the same as the Node field returned by function Mean. That is,
174 * radians, referenced to mean dynamical ecliptic and equinox of date.
175 */
176function node(p, jde) {
177 // (p int, jde float64) float64
178 return _base2.default.horner(_base2.default.J2000Century(jde), cMean[p].Ω) * Math.PI / 180;
179}
180
181exports.default = {
182 mercury: mercury,
183 venus: venus,
184 earth: earth,
185 mars: mars,
186 jupiter: jupiter,
187 saturn: saturn,
188 uranus: uranus,
189 neptune: neptune,
190 Elements: Elements,
191 mean: mean,
192 inc: inc,
193 node: node
194};
\No newline at end of file