1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.Planet = 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 | * @copyright 2013 Sonia Keys
|
14 | * @copyright 2016 commenthol
|
15 | * @license MIT
|
16 | * @module planetposition
|
17 | */
|
18 | /**
|
19 | * Planetposition: Chapter 32, Positions of the Planets.
|
20 | *
|
21 | * Incomplete:
|
22 | *
|
23 | * 1. The package does not implement algorithms that use appendix III,
|
24 | * but instead implements a full VSOP87 solution. I do not have a copy
|
25 | * of the supplimentary disk with appendix III in machine readable form
|
26 | * and as the appendix is rather large, retyping it by hand is problematic.
|
27 | * The full VSOP87 data set on the other hand is freely downloadable from
|
28 | * the internet, so I implement here code that can use that data directly.
|
29 | *
|
30 | * 2. The formula for accuracy of results is not implemented. It is
|
31 | * not needed for full VSOP87 solutions.
|
32 | *
|
33 | * 3. Polynomial expressions are not implemented. Again, implementation
|
34 | * would involve typing rather large tables of numbers with associated
|
35 | * risk of typographical errors.
|
36 | */
|
37 |
|
38 | exports.toFK5 = toFK5;
|
39 |
|
40 | var _base = require('./base');
|
41 |
|
42 | var _base2 = _interopRequireDefault(_base);
|
43 |
|
44 | var _sexagesimal = require('./sexagesimal');
|
45 |
|
46 | var _sexagesimal2 = _interopRequireDefault(_sexagesimal);
|
47 |
|
48 | var _coord = require('./coord');
|
49 |
|
50 | var _coord2 = _interopRequireDefault(_coord);
|
51 |
|
52 | var _precess = require('./precess');
|
53 |
|
54 | var _precess2 = _interopRequireDefault(_precess);
|
55 |
|
56 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
57 |
|
58 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
59 |
|
60 | function sum(t, series) {
|
61 | var coeffs = [];
|
62 | Object.keys(series).forEach(function (x) {
|
63 | coeffs[x] = 0;
|
64 | var y = series[x].length - 1;
|
65 | for (y; y >= 0; y--) {
|
66 | var term = {
|
67 | a: series[x][y][0],
|
68 | b: series[x][y][1],
|
69 | c: series[x][y][2]
|
70 | };
|
71 | coeffs[x] += term.a * Math.cos(term.b + term.c * t);
|
72 | }
|
73 | });
|
74 | var res = _base2.default.horner(t, coeffs);
|
75 | return res;
|
76 | }
|
77 |
|
78 | var Planet = exports.Planet = function () {
|
79 | /**
|
80 | * VSOP87 representation of a Planet
|
81 | * @constructs Planet
|
82 | * @param {object} planet - planet data series
|
83 | * @example
|
84 | * ```js
|
85 | * // for use in browser
|
86 | * import {data} from 'astronomia'
|
87 | * const earth = new planetposition.Planet(data.vsop87Bearth)
|
88 | * ```
|
89 | */
|
90 | function Planet(planet) {
|
91 | _classCallCheck(this, Planet);
|
92 |
|
93 | if ((typeof planet === 'undefined' ? 'undefined' : _typeof(planet)) !== 'object') throw new TypeError('need planet vsop87 data');
|
94 | this.name = planet.name;
|
95 | this.series = planet;
|
96 | }
|
97 |
|
98 | /**
|
99 | * Position2000 returns ecliptic position of planets by full VSOP87 theory.
|
100 | *
|
101 | * @param {Number} jde - the date for which positions are desired.
|
102 | * @returns {base.Coord} Results are for the dynamical equinox and ecliptic J2000.
|
103 | * {Number} lon - heliocentric longitude in radians.
|
104 | * {Number} lat - heliocentric latitude in radians.
|
105 | * {Number} range - heliocentric range in AU.
|
106 | */
|
107 |
|
108 |
|
109 | _createClass(Planet, [{
|
110 | key: 'position2000',
|
111 | value: function position2000(jde) {
|
112 | var T = _base2.default.J2000Century(jde);
|
113 | var τ = T * 0.1;
|
114 | var lon = _base2.default.pmod(sum(τ, this.series.L), 2 * Math.PI);
|
115 | var lat = sum(τ, this.series.B);
|
116 | var range = sum(τ, this.series.R);
|
117 | return new _base2.default.Coord(lon, lat, range);
|
118 | }
|
119 |
|
120 | /**
|
121 | * Position returns ecliptic position of planets at equinox and ecliptic of date.
|
122 | *
|
123 | * @param {Number} jde - the date for which positions are desired.
|
124 | * @returns {base.Coord} Results are positions consistent with those from Meeus's
|
125 | * Apendix III, that is, at equinox and ecliptic of date.
|
126 | * {Number} lon - heliocentric longitude in radians.
|
127 | * {Number} lat - heliocentric latitude in radians.
|
128 | * {Number} range - heliocentric range in AU.
|
129 | */
|
130 |
|
131 | }, {
|
132 | key: 'position',
|
133 | value: function position(jde) {
|
134 | var _position = this.position2000(jde),
|
135 | lat = _position.lat,
|
136 | lon = _position.lon,
|
137 | range = _position.range;
|
138 |
|
139 | var eclFrom = new _coord2.default.Ecliptic(lon, lat);
|
140 | var epochFrom = 2000.0;
|
141 | var epochTo = _base2.default.JDEToJulianYear(jde);
|
142 | var eclTo = _precess2.default.eclipticPosition(eclFrom, epochFrom, epochTo, 0, 0);
|
143 | return new _base2.default.Coord(eclTo.lon, eclTo.lat, range);
|
144 | }
|
145 | }]);
|
146 |
|
147 | return Planet;
|
148 | }();
|
149 |
|
150 | /**
|
151 | * ToFK5 converts ecliptic longitude and latitude from dynamical frame to FK5.
|
152 | *
|
153 | * @param {Number} lon - ecliptic longitude in radians
|
154 | * @param {Number} lat - ecliptic latitude in radians
|
155 | * @param {Number} jde - Julian ephemeris day
|
156 | * @return {base.Coord}
|
157 | * {Number} lon - FK5 longitude
|
158 | * {Number} lat - FK5 latitude
|
159 | */
|
160 |
|
161 |
|
162 | function toFK5(lon, lat, jde) {
|
163 | // formula 32.3, p. 219.
|
164 | var T = _base2.default.J2000Century(jde);
|
165 | // const Lp = lon - 1.397 * Math.PI / 180 * T - 0.00031 * Math.PI / 180 * T * T
|
166 | var Lp = lon - _sexagesimal2.default.angleFromDeg((1.397 + 0.00031 * T) * T);
|
167 |
|
168 | var _base$sincos = _base2.default.sincos(Lp),
|
169 | _base$sincos2 = _slicedToArray(_base$sincos, 2),
|
170 | sLp = _base$sincos2[0],
|
171 | cLp = _base$sincos2[1];
|
172 | // (32.3) p. 219
|
173 |
|
174 |
|
175 | var L5 = lon + _sexagesimal2.default.angleFromSec(-0.09033 + 0.03916 * (cLp + sLp) * Math.tan(lat));
|
176 | var B5 = lat + _sexagesimal2.default.angleFromSec(0.03916 * (cLp - sLp));
|
177 | return new _base2.default.Coord(L5, B5);
|
178 | }
|
179 |
|
180 | exports.default = {
|
181 | Planet: Planet,
|
182 | toFK5: toFK5
|
183 | }; |
\ | No newline at end of file |