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