UNPKG

12.8 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _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 parallax
12 */
13/**
14 * Parallax: Chapter 40, Correction for Parallax.
15 */
16
17exports.horizontal = horizontal;
18exports.topocentric = topocentric;
19exports.topocentric2 = topocentric2;
20exports.topocentric3 = topocentric3;
21exports.topocentricEcliptical = topocentricEcliptical;
22
23var _base = require('./base');
24
25var _base2 = _interopRequireDefault(_base);
26
27var _globe = require('./globe');
28
29var _globe2 = _interopRequireDefault(_globe);
30
31var _sidereal = require('./sidereal');
32
33var _sidereal2 = _interopRequireDefault(_sidereal);
34
35var _sexagesimal = require('./sexagesimal');
36
37var _sexagesimal2 = _interopRequireDefault(_sexagesimal);
38
39function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40
41var horPar = 8.794 / 3600 * Math.PI / 180; // 8".794 arcseconds in radians
42
43/**
44 * Horizontal returns equatorial horizontal parallax of a body.
45 *
46 * @param {number} Δ - distance in AU.
47 * @return {number} parallax in radians.
48 */
49function horizontal(Δ) {
50 // (40.1) p. 279
51 return Math.asin(Math.sin(horPar) / Δ);
52 // return horPar / Δ // with sufficient accuracy
53}
54
55/**
56 * Topocentric returns topocentric positions including parallax.
57 *
58 * Arguments α, δ are geocentric right ascension and declination in radians.
59 * Δ is distance to the observed object in AU. ρsφ_, ρcφ_ are parallax
60 * constants (see package globe.) lon is geographic longitude of the observer,
61 * jde is time of observation.
62 *
63 * @param {base.Coord} c - geocentric right ascension and declination in radians
64 * @param {number} ρsφ - parallax constants (see package globe.)
65 * @param {number} ρcφ - parallax constants (see package globe.)
66 * @param {number} lon - geographic longitude of the observer (measured positively westwards!)
67 * @param {number} jde - time of observation
68 * @return {base.Coord} observed topocentric ra and dec in radians.
69 */
70function topocentric(c, ρsφ, ρcφ, lon, jde) {
71 var _ref = [c.ra, c.dec, c.range],
72 α = _ref[0],
73 δ = _ref[1],
74 Δ = _ref[2];
75
76 var π = horizontal(Δ);
77 var θ0 = new _sexagesimal2.default.Time(_sidereal2.default.apparent(jde)).rad();
78 var H = _base2.default.pmod(θ0 - lon - α, 2 * Math.PI);
79 var sπ = Math.sin(π);
80
81 var _base$sincos = _base2.default.sincos(H),
82 _base$sincos2 = _slicedToArray(_base$sincos, 2),
83 sH = _base$sincos2[0],
84 cH = _base$sincos2[1];
85
86 var _base$sincos3 = _base2.default.sincos(δ),
87 _base$sincos4 = _slicedToArray(_base$sincos3, 2),
88 sδ = _base$sincos4[0],
89 cδ = _base$sincos4[1];
90
91 var Δα = Math.atan2(-ρcφ * sπ * sH, cδ - ρcφ * sπ * cH); // (40.2) p. 279
92 var α_ = α + Δα;
93 var δ_ = Math.atan2((sδ - ρsφ * sπ) * Math.cos(Δα), cδ - ρcφ * sπ * cH); // (40.3) p. 279
94 return new _base2.default.Coord(α_, δ_);
95}
96
97/**
98 * Topocentric2 returns topocentric corrections including parallax.
99 *
100 * This function implements the "non-rigorous" method descripted in the text.
101 *
102 * Note that results are corrections, not corrected coordinates.
103 *
104 * @param {base.Coord} c - geocentric right ascension and declination in radians
105 * @param {number} ρsφ - parallax constants (see package globe.)
106 * @param {number} ρcφ - parallax constants (see package globe.)
107 * @param {number} lon - geographic longitude of the observer (measured positively westwards!)
108 * @param {number} jde - time of observation
109 * @return {base.Coord} observed topocentric ra and dec in radians.
110 */
111function topocentric2(c, ρsφ, ρcφ, lon, jde) {
112 var _ref2 = [c.ra, c.dec, c.range],
113 α = _ref2[0],
114 δ = _ref2[1],
115 Δ = _ref2[2];
116
117 var π = horizontal(Δ);
118 var θ0 = new _sexagesimal2.default.Time(_sidereal2.default.apparent(jde)).rad();
119 var H = _base2.default.pmod(θ0 - lon - α, 2 * Math.PI);
120
121 var _base$sincos5 = _base2.default.sincos(H),
122 _base$sincos6 = _slicedToArray(_base$sincos5, 2),
123 sH = _base$sincos6[0],
124 cH = _base$sincos6[1];
125
126 var _base$sincos7 = _base2.default.sincos(δ),
127 _base$sincos8 = _slicedToArray(_base$sincos7, 2),
128 sδ = _base$sincos8[0],
129 cδ = _base$sincos8[1];
130
131 var Δα = -π * ρcφ * sH / cδ; // (40.4) p. 280
132 var Δδ = -π * (ρsφ * cδ - ρcφ * cH * sδ); // (40.5) p. 280
133 return new _base2.default.Coord(Δα, Δδ);
134}
135
136/**
137 * Topocentric3 returns topocentric hour angle and declination including parallax.
138 *
139 * This function implements the "alternative" method described in the text.
140 * The method should be similarly rigorous to that of Topocentric() and results
141 * should be virtually consistent.
142 *
143 * @param {base.Coord} c - geocentric right ascension and declination in radians
144 * @param {number} ρsφ - parallax constants (see package globe.)
145 * @param {number} ρcφ - parallax constants (see package globe.)
146 * @param {number} lon - geographic longitude of the observer (measured positively westwards!)
147 * @param {number} jde - time of observation
148 * @return {Array}
149 * {number} H_ - topocentric hour angle
150 * {number} δ_ - topocentric declination
151 */
152function topocentric3(c, ρsφ_, ρcφ_, lon, jde) {
153 var _ref3 = [c.ra, c.dec, c.range],
154 α = _ref3[0],
155 δ = _ref3[1],
156 Δ = _ref3[2];
157
158 var π = horizontal(Δ);
159 var θ0 = new _sexagesimal2.default.Time(_sidereal2.default.apparent(jde)).rad();
160 var H = _base2.default.pmod(θ0 - lon - α, 2 * Math.PI);
161 var sπ = Math.sin(π);
162
163 var _base$sincos9 = _base2.default.sincos(H),
164 _base$sincos10 = _slicedToArray(_base$sincos9, 2),
165 sH = _base$sincos10[0],
166 cH = _base$sincos10[1];
167
168 var _base$sincos11 = _base2.default.sincos(δ),
169 _base$sincos12 = _slicedToArray(_base$sincos11, 2),
170 sδ = _base$sincos12[0],
171 cδ = _base$sincos12[1];
172
173 var A = cδ * sH;
174 var B = cδ * cH - ρcφ_ * sπ;
175 var C = sδ - ρsφ_ * sπ;
176 var q = Math.sqrt(A * A + B * B + C * C);
177 var H_ = Math.atan2(A, B);
178 var δ_ = Math.asin(C / q);
179 return [H_, δ_];
180}
181
182/**
183 * TopocentricEcliptical returns topocentric ecliptical coordinates including parallax.
184 *
185 * Arguments `c` are geocentric ecliptical longitude and latitude of a body,
186 * s is its geocentric semidiameter. φ, h are the observer's latitude and
187 * and height above the ellipsoid in meters. ε is the obliquity of the
188 * ecliptic, θ is local sidereal time, π is equatorial horizontal parallax
189 * of the body (see Horizonal()).
190 *
191 * All angular parameters and results are in radians.
192 *
193 * @param {base.Coord} c - geocentric right ascension and declination in radians
194 * @param {number} s - geocentric semidiameter of `c`
195 * @param {number} φ - observer's latitude
196 * @param {number} h - observer's height above the ellipsoid in meters
197 * @param {number} ε - is the obliquity of the ecliptic
198 * @param {number} θ - local sidereal time
199 * @param {number} π - equatorial horizontal parallax of the body
200 * @return {Array}
201 * {number} λ_ - observed topocentric longitude
202 * {number} β_ - observed topocentric latitude
203 * {number} s_ - observed topocentric semidiameter
204 */
205function topocentricEcliptical(c, s, φ, h, ε, θ, π) {
206 var _ref4 = [c.lon, c.lat],
207 λ = _ref4[0],
208 β = _ref4[1];
209
210 var _globe$Earth76$parall = _globe2.default.Earth76.parallaxConstants(φ, h),
211 _globe$Earth76$parall2 = _slicedToArray(_globe$Earth76$parall, 2),
212 S = _globe$Earth76$parall2[0],
213 C = _globe$Earth76$parall2[1];
214
215 var _base$sincos13 = _base2.default.sincos(λ),
216 _base$sincos14 = _slicedToArray(_base$sincos13, 2),
217 sλ = _base$sincos14[0],
218 cλ = _base$sincos14[1];
219
220 var _base$sincos15 = _base2.default.sincos(β),
221 _base$sincos16 = _slicedToArray(_base$sincos15, 2),
222 sβ = _base$sincos16[0],
223 cβ = _base$sincos16[1];
224
225 var _base$sincos17 = _base2.default.sincos(ε),
226 _base$sincos18 = _slicedToArray(_base$sincos17, 2),
227 sε = _base$sincos18[0],
228 cε = _base$sincos18[1];
229
230 var _base$sincos19 = _base2.default.sincos(θ),
231 _base$sincos20 = _slicedToArray(_base$sincos19, 2),
232 sθ = _base$sincos20[0],
233 cθ = _base$sincos20[1];
234
235 var sπ = Math.sin(π);
236 var N = cλ * cβ - C * sπ * cθ;
237 var λ_ = Math.atan2(sλ * cβ - sπ * (S * sε + C * cε * sθ), N);
238 if (λ_ < 0) {
239 λ_ += 2 * Math.PI;
240 }
241 var cλ_ = Math.cos(λ_);
242 var β_ = Math.atan(cλ_ * (sβ - sπ * (S * cε - C * sε * sθ)) / N);
243 var s_ = Math.asin(cλ_ * Math.cos(β_) * Math.sin(s) / N);
244 return [λ_, β_, s_];
245}
246
247exports.default = {
248 horizontal: horizontal,
249 topocentric: topocentric,
250 topocentric2: topocentric2,
251 topocentric3: topocentric3,
252 topocentricEcliptical: topocentricEcliptical
253};
\No newline at end of file