1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.galactic0Lon1950 = exports.galacticLon0 = exports.galacticNorth1950 = exports.galacticNorth = exports.Galactic = exports.Horizontal = exports.Equatorial = exports.Ecliptic = undefined;
|
7 |
|
8 | 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"); } }; }();
|
9 |
|
10 | 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; };
|
11 |
|
12 | 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; }; }(); |
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | var _base = require('./base');
|
43 |
|
44 | var _base2 = _interopRequireDefault(_base);
|
45 |
|
46 | var _sexagesimal = require('./sexagesimal');
|
47 |
|
48 | var _sexagesimal2 = _interopRequireDefault(_sexagesimal);
|
49 |
|
50 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
51 |
|
52 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
53 |
|
54 |
|
55 |
|
56 |
|
57 | var Ecliptic = exports.Ecliptic = function () {
|
58 | |
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | function Ecliptic(lon, lat) {
|
65 | _classCallCheck(this, Ecliptic);
|
66 |
|
67 | if ((typeof lon === 'undefined' ? 'undefined' : _typeof(lon)) === 'object') {
|
68 | lat = lon.lat;
|
69 | lon = lon.lon;
|
70 | }
|
71 | this.lon = lon || 0;
|
72 | this.lat = lat || 0;
|
73 | }
|
74 |
|
75 | |
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 | _createClass(Ecliptic, [{
|
83 | key: 'toEquatorial',
|
84 | value: function toEquatorial(ε) {
|
85 | var _base$sincos = _base2.default.sincos(ε),
|
86 | _base$sincos2 = _slicedToArray(_base$sincos, 2),
|
87 | εsin = _base$sincos2[0],
|
88 | εcos = _base$sincos2[1];
|
89 |
|
90 | var _base$sincos3 = _base2.default.sincos(this.lat),
|
91 | _base$sincos4 = _slicedToArray(_base$sincos3, 2),
|
92 | sβ = _base$sincos4[0],
|
93 | cβ = _base$sincos4[1];
|
94 |
|
95 | var _base$sincos5 = _base2.default.sincos(this.lon),
|
96 | _base$sincos6 = _slicedToArray(_base$sincos5, 2),
|
97 | sλ = _base$sincos6[0],
|
98 | cλ = _base$sincos6[1];
|
99 |
|
100 | var ra = Math.atan2(sλ * εcos - sβ / cβ * εsin, cλ);
|
101 | if (ra < 0) {
|
102 | ra += 2 * Math.PI;
|
103 | }
|
104 | var dec = Math.asin(sβ * εcos + cβ * εsin * sλ);
|
105 | return new Equatorial(ra, dec);
|
106 | }
|
107 | }]);
|
108 |
|
109 | return Ecliptic;
|
110 | }();
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 | var Equatorial = exports.Equatorial = function () {
|
118 | |
119 |
|
120 |
|
121 |
|
122 | function Equatorial() {
|
123 | var ra = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
124 | var dec = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
125 |
|
126 | _classCallCheck(this, Equatorial);
|
127 |
|
128 | this.ra = ra;
|
129 | this.dec = dec;
|
130 | }
|
131 |
|
132 | |
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 | _createClass(Equatorial, [{
|
140 | key: 'toEcliptic',
|
141 | value: function toEcliptic(ε) {
|
142 | var _base$sincos7 = _base2.default.sincos(ε),
|
143 | _base$sincos8 = _slicedToArray(_base$sincos7, 2),
|
144 | εsin = _base$sincos8[0],
|
145 | εcos = _base$sincos8[1];
|
146 |
|
147 | var _base$sincos9 = _base2.default.sincos(this.ra),
|
148 | _base$sincos10 = _slicedToArray(_base$sincos9, 2),
|
149 | sα = _base$sincos10[0],
|
150 | cα = _base$sincos10[1];
|
151 |
|
152 | var _base$sincos11 = _base2.default.sincos(this.dec),
|
153 | _base$sincos12 = _slicedToArray(_base$sincos11, 2),
|
154 | sδ = _base$sincos12[0],
|
155 | cδ = _base$sincos12[1];
|
156 |
|
157 | var lon = Math.atan2(sα * εcos + sδ / cδ * εsin, cα);
|
158 | var lat = Math.asin(sδ * εcos - cδ * εsin * sα);
|
159 | return new Ecliptic(lon, lat);
|
160 | }
|
161 |
|
162 | |
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 | }, {
|
178 | key: 'toHorizontal',
|
179 | value: function toHorizontal(g, st) {
|
180 | var H = new _sexagesimal2.default.Time(st).rad() - g.lon - this.ra;
|
181 |
|
182 | var _base$sincos13 = _base2.default.sincos(H),
|
183 | _base$sincos14 = _slicedToArray(_base$sincos13, 2),
|
184 | sH = _base$sincos14[0],
|
185 | cH = _base$sincos14[1];
|
186 |
|
187 | var _base$sincos15 = _base2.default.sincos(g.lat),
|
188 | _base$sincos16 = _slicedToArray(_base$sincos15, 2),
|
189 | sφ = _base$sincos16[0],
|
190 | cφ = _base$sincos16[1];
|
191 |
|
192 | var _base$sincos17 = _base2.default.sincos(this.dec),
|
193 | _base$sincos18 = _slicedToArray(_base$sincos17, 2),
|
194 | sδ = _base$sincos18[0],
|
195 | cδ = _base$sincos18[1];
|
196 |
|
197 | var azimuth = Math.atan2(sH, cH * sφ - sδ / cδ * cφ);
|
198 | var altitude = Math.asin(sφ * sδ + cφ * cδ * cH);
|
199 | return new Horizontal(azimuth, altitude);
|
200 | }
|
201 |
|
202 | |
203 |
|
204 |
|
205 |
|
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 | }, {
|
214 | key: 'toGalactic',
|
215 | value: function toGalactic() {
|
216 | var _base$sincos19 = _base2.default.sincos(galacticNorth1950.ra - this.ra),
|
217 | _base$sincos20 = _slicedToArray(_base$sincos19, 2),
|
218 | sdα = _base$sincos20[0],
|
219 | cdα = _base$sincos20[1];
|
220 |
|
221 | var _base$sincos21 = _base2.default.sincos(galacticNorth1950.dec),
|
222 | _base$sincos22 = _slicedToArray(_base$sincos21, 2),
|
223 | sgδ = _base$sincos22[0],
|
224 | cgδ = _base$sincos22[1];
|
225 |
|
226 | var _base$sincos23 = _base2.default.sincos(this.dec),
|
227 | _base$sincos24 = _slicedToArray(_base$sincos23, 2),
|
228 | sδ = _base$sincos24[0],
|
229 | cδ = _base$sincos24[1];
|
230 |
|
231 | var x = Math.atan2(sdα, cdα * sgδ - sδ / cδ * cgδ);
|
232 |
|
233 | var lon = (galactic0Lon1950 + 1.5 * Math.PI - x) % (2 * Math.PI);
|
234 | var lat = Math.asin(sδ * sgδ + cδ * cgδ * cdα);
|
235 | return new Galactic(lon, lat);
|
236 | }
|
237 | }]);
|
238 |
|
239 | return Equatorial;
|
240 | }();
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 | var Horizontal = exports.Horizontal = function () {
|
251 | function Horizontal() {
|
252 | var az = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
253 | var alt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
254 |
|
255 | _classCallCheck(this, Horizontal);
|
256 |
|
257 | this.az = az;
|
258 | this.alt = alt;
|
259 | }
|
260 |
|
261 | |
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 | _createClass(Horizontal, [{
|
273 | key: 'toEquatorial',
|
274 | value: function toEquatorial(g, st) {
|
275 | var _base$sincos25 = _base2.default.sincos(this.az),
|
276 | _base$sincos26 = _slicedToArray(_base$sincos25, 2),
|
277 | sA = _base$sincos26[0],
|
278 | cA = _base$sincos26[1];
|
279 |
|
280 | var _base$sincos27 = _base2.default.sincos(this.alt),
|
281 | _base$sincos28 = _slicedToArray(_base$sincos27, 2),
|
282 | sh = _base$sincos28[0],
|
283 | ch = _base$sincos28[1];
|
284 |
|
285 | var _base$sincos29 = _base2.default.sincos(g.lat),
|
286 | _base$sincos30 = _slicedToArray(_base$sincos29, 2),
|
287 | sφ = _base$sincos30[0],
|
288 | cφ = _base$sincos30[1];
|
289 |
|
290 | var H = Math.atan2(sA, cA * sφ + sh / ch * cφ);
|
291 | var ra = _base2.default.pmod(new _sexagesimal2.default.Time(st).rad() - g.lon - H, 2 * Math.PI);
|
292 | var dec = Math.asin(sφ * sh - cφ * ch * cA);
|
293 | return new Equatorial(ra, dec);
|
294 | }
|
295 | }]);
|
296 |
|
297 | return Horizontal;
|
298 | }();
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 | var Galactic = exports.Galactic = function () {
|
308 | function Galactic() {
|
309 | var lon = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
310 | var lat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
311 |
|
312 | _classCallCheck(this, Galactic);
|
313 |
|
314 | this.lon = lon;
|
315 | this.lat = lat;
|
316 | }
|
317 |
|
318 | |
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 | _createClass(Galactic, [{
|
330 | key: 'toEquatorial',
|
331 | value: function toEquatorial() {
|
332 |
|
333 | var _base$sincos31 = _base2.default.sincos(this.lon - galactic0Lon1950 - Math.PI / 2),
|
334 | _base$sincos32 = _slicedToArray(_base$sincos31, 2),
|
335 | sdLon = _base$sincos32[0],
|
336 | cdLon = _base$sincos32[1];
|
337 |
|
338 | var _base$sincos33 = _base2.default.sincos(galacticNorth1950.dec),
|
339 | _base$sincos34 = _slicedToArray(_base$sincos33, 2),
|
340 | sgδ = _base$sincos34[0],
|
341 | cgδ = _base$sincos34[1];
|
342 |
|
343 | var _base$sincos35 = _base2.default.sincos(this.lat),
|
344 | _base$sincos36 = _slicedToArray(_base$sincos35, 2),
|
345 | sb = _base$sincos36[0],
|
346 | cb = _base$sincos36[1];
|
347 |
|
348 | var y = Math.atan2(sdLon, cdLon * sgδ - sb / cb * cgδ);
|
349 |
|
350 | var ra = _base2.default.pmod(y + galacticNorth1950.ra - Math.PI, 2 * Math.PI);
|
351 | var dec = Math.asin(sb * sgδ + cb * cgδ * cdLon);
|
352 | return new Equatorial(ra, dec);
|
353 | }
|
354 | }]);
|
355 |
|
356 | return Galactic;
|
357 | }();
|
358 |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 | var galacticNorth = exports.galacticNorth = new Equatorial(new _sexagesimal2.default.RA(12, 49, 0).rad(), 27.4 * Math.PI / 180);
|
366 | var galacticNorth1950 = exports.galacticNorth1950 = galacticNorth;
|
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 | var galacticLon0 = exports.galacticLon0 = 33 * Math.PI / 180;
|
375 | var galactic0Lon1950 = exports.galactic0Lon1950 = galacticLon0;
|
376 |
|
377 | exports.default = {
|
378 | Ecliptic: Ecliptic,
|
379 | Equatorial: Equatorial,
|
380 | Horizontal: Horizontal,
|
381 | Galactic: Galactic,
|
382 | galacticNorth: galacticNorth,
|
383 | galacticNorth1950: galacticNorth1950,
|
384 | galacticLon0: galacticLon0,
|
385 | galactic0Lon1950: galactic0Lon1950
|
386 | }; |
\ | No newline at end of file |