UNPKG

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