1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | 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"); } }; }(); /**
|
8 | * @copyright 2013 Sonia Keys
|
9 | * @copyright 2016 commenthol
|
10 | * @license MIT
|
11 | * @module solarxyz
|
12 | */
|
13 | /**
|
14 | * Solarxyz: Chapter 26, Rectangular Coordinates of the Sun.
|
15 | */
|
16 |
|
17 |
|
18 | exports.position = position;
|
19 | exports.longitudeJ2000 = longitudeJ2000;
|
20 | exports.positionJ2000 = positionJ2000;
|
21 | exports.xyz = xyz;
|
22 | exports.positionB1950 = positionB1950;
|
23 | exports.positionEquinox = positionEquinox;
|
24 |
|
25 | var _base = require('./base');
|
26 |
|
27 | var _base2 = _interopRequireDefault(_base);
|
28 |
|
29 | var _nutation = require('./nutation');
|
30 |
|
31 | var _nutation2 = _interopRequireDefault(_nutation);
|
32 |
|
33 | var _solar = require('./solar');
|
34 |
|
35 | var _solar2 = _interopRequireDefault(_solar);
|
36 |
|
37 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
38 |
|
39 | /**
|
40 | * Position returns rectangular coordinates referenced to the mean equinox of date.
|
41 | * @param {planetposition.Planet} earth - VSOP87Planet Earth
|
42 | * @param {Number} jde - Julian ephemeris day
|
43 | * @return {object} rectangular coordinates
|
44 | * {Number} x
|
45 | * {Number} y
|
46 | * {Number} z
|
47 | */
|
48 | function position(earth, jde) {
|
49 | // (e *pp.V87Planet, jde float64) (x, y, z float64)
|
50 | // (26.1) p. 171
|
51 | var _solar$trueVSOP = _solar2.default.trueVSOP87(earth, jde),
|
52 | lon = _solar$trueVSOP.lon,
|
53 | lat = _solar$trueVSOP.lat,
|
54 | range = _solar$trueVSOP.range;
|
55 |
|
56 | var _base$sincos = _base2.default.sincos(_nutation2.default.meanObliquity(jde)),
|
57 | _base$sincos2 = _slicedToArray(_base$sincos, 2),
|
58 | sε = _base$sincos2[0],
|
59 | cε = _base$sincos2[1];
|
60 |
|
61 | var _base$sincos3 = _base2.default.sincos(lon),
|
62 | _base$sincos4 = _slicedToArray(_base$sincos3, 2),
|
63 | ss = _base$sincos4[0],
|
64 | cs = _base$sincos4[1];
|
65 |
|
66 | var sβ = Math.sin(lat);
|
67 | var x = range * cs;
|
68 | var y = range * (ss * cε - sβ * sε);
|
69 | var z = range * (ss * sε + sβ * cε);
|
70 | return { x: x, y: y, z: z };
|
71 | }
|
72 |
|
73 | /**
|
74 | * LongitudeJ2000 returns geometric longitude referenced to equinox J2000.
|
75 | * @param {planetposition.Planet} earth - VSOP87Planet Earth
|
76 | * @param {Number} jde - Julian ephemeris day
|
77 | * @return {Number} geometric longitude referenced to equinox J2000.
|
78 | */
|
79 | function longitudeJ2000(earth, jde) {
|
80 | var lon = earth.position2000(jde).lon;
|
81 | return _base2.default.pmod(lon + Math.PI - 0.09033 / 3600 * Math.PI / 180, 2 * Math.PI);
|
82 | }
|
83 |
|
84 | /**
|
85 | * PositionJ2000 returns rectangular coordinates referenced to equinox J2000.
|
86 | * @param {planetposition.Planet} earth - VSOP87Planet Earth
|
87 | * @param {Number} jde - Julian ephemeris day
|
88 | * @return {object} rectangular coordinates
|
89 | * {Number} x
|
90 | * {Number} y
|
91 | * {Number} z
|
92 | */
|
93 | function positionJ2000(earth, jde) {
|
94 | var _xyz = xyz(earth, jde),
|
95 | x = _xyz.x,
|
96 | y = _xyz.y,
|
97 | z = _xyz.z;
|
98 | // (26.3) p. 174
|
99 |
|
100 |
|
101 | return {
|
102 | x: x + 0.00000044036 * y - 0.000000190919 * z,
|
103 | y: -0.000000479966 * x + 0.917482137087 * y - 0.397776982902 * z,
|
104 | z: 0.397776982902 * y + 0.917482137087 * z
|
105 | };
|
106 | }
|
107 |
|
108 | function xyz(earth, jde) {
|
109 | var _earth$position = earth.position2000(jde),
|
110 | lon = _earth$position.lon,
|
111 | lat = _earth$position.lat,
|
112 | range = _earth$position.range;
|
113 |
|
114 | var s = lon + Math.PI;
|
115 | var β = -lat;
|
116 |
|
117 | var _base$sincos5 = _base2.default.sincos(s),
|
118 | _base$sincos6 = _slicedToArray(_base$sincos5, 2),
|
119 | ss = _base$sincos6[0],
|
120 | cs = _base$sincos6[1];
|
121 |
|
122 | var _base$sincos7 = _base2.default.sincos(β),
|
123 | _base$sincos8 = _slicedToArray(_base$sincos7, 2),
|
124 | sβ = _base$sincos8[0],
|
125 | cβ = _base$sincos8[1];
|
126 | // (26.2) p. 172
|
127 |
|
128 |
|
129 | var x = range * cβ * cs;
|
130 | var y = range * cβ * ss;
|
131 | var z = range * sβ;
|
132 | return { x: x, y: y, z: z };
|
133 | }
|
134 |
|
135 | /**
|
136 | * PositionB1950 returns rectangular coordinates referenced to B1950.
|
137 | *
|
138 | * Results are referenced to the mean equator and equinox of the epoch B1950
|
139 | * in the FK5 system, not FK4.
|
140 | *
|
141 | * @param {planetposition.Planet} earth - VSOP87Planet Earth
|
142 | * @param {Number} jde - Julian ephemeris day
|
143 | * @return {object} rectangular coordinates
|
144 | * {Number} x
|
145 | * {Number} y
|
146 | * {Number} z
|
147 | */
|
148 | function positionB1950(earth, jde) {
|
149 | // (e *pp.V87Planet, jde float64) (x, y, z float64)
|
150 | var _xyz2 = xyz(earth, jde),
|
151 | x = _xyz2.x,
|
152 | y = _xyz2.y,
|
153 | z = _xyz2.z;
|
154 |
|
155 | return {
|
156 | x: 0.999925702634 * x + 0.012189716217 * y + 0.000011134016 * z,
|
157 | y: -0.011179418036 * x + 0.917413998946 * y - 0.397777041885 * z,
|
158 | z: -0.004859003787 * x + 0.397747363646 * y + 0.917482111428 * z
|
159 | };
|
160 | }
|
161 |
|
162 | var ζt = [2306.2181, 0.30188, 0.017998];
|
163 | var zt = [2306.2181, 1.09468, 0.018203];
|
164 | var θt = [2004.3109, -0.42665, -0.041833];
|
165 |
|
166 | /**
|
167 | * PositionEquinox returns rectangular coordinates referenced to an arbitrary epoch.
|
168 | *
|
169 | * Position will be computed for given Julian day "jde" but referenced to mean
|
170 | * equinox "epoch" (year).
|
171 | *
|
172 | * @param {planetposition.Planet} earth - VSOP87Planet Earth
|
173 | * @param {Number} jde - Julian ephemeris day
|
174 | * @param {Number} epoch
|
175 | * @return {object} rectangular coordinates
|
176 | * {Number} x
|
177 | * {Number} y
|
178 | * {Number} z
|
179 | */
|
180 | function positionEquinox(earth, jde, epoch) {
|
181 | var xyz = positionJ2000(earth, jde);
|
182 | var x0 = xyz.x;
|
183 | var y0 = xyz.y;
|
184 | var z0 = xyz.z;
|
185 | var t = (epoch - 2000) * 0.01;
|
186 | var ζ = _base2.default.horner(t, ζt) * t * Math.PI / 180 / 3600;
|
187 | var z = _base2.default.horner(t, zt) * t * Math.PI / 180 / 3600;
|
188 | var θ = _base2.default.horner(t, θt) * t * Math.PI / 180 / 3600;
|
189 |
|
190 | var _base$sincos9 = _base2.default.sincos(ζ),
|
191 | _base$sincos10 = _slicedToArray(_base$sincos9, 2),
|
192 | sζ = _base$sincos10[0],
|
193 | cζ = _base$sincos10[1];
|
194 |
|
195 | var _base$sincos11 = _base2.default.sincos(z),
|
196 | _base$sincos12 = _slicedToArray(_base$sincos11, 2),
|
197 | sz = _base$sincos12[0],
|
198 | cz = _base$sincos12[1];
|
199 |
|
200 | var _base$sincos13 = _base2.default.sincos(θ),
|
201 | _base$sincos14 = _slicedToArray(_base$sincos13, 2),
|
202 | sθ = _base$sincos14[0],
|
203 | cθ = _base$sincos14[1];
|
204 |
|
205 | var xx = cζ * cz * cθ - sζ * sz;
|
206 | var xy = sζ * cz + cζ * sz * cθ;
|
207 | var xz = cζ * sθ;
|
208 | var yx = -cζ * sz - sζ * cz * cθ;
|
209 | var yy = cζ * cz - sζ * sz * cθ;
|
210 | var yz = -sζ * sθ;
|
211 | var zx = -cz * sθ;
|
212 | var zy = -sz * sθ;
|
213 | var zz = cθ;
|
214 | return {
|
215 | x: xx * x0 + yx * y0 + zx * z0,
|
216 | y: xy * x0 + yy * y0 + zy * z0,
|
217 | z: xz * x0 + yz * y0 + zz * z0
|
218 | };
|
219 | }
|
220 |
|
221 | exports.default = {
|
222 | position: position,
|
223 | longitudeJ2000: longitudeJ2000,
|
224 | positionJ2000: positionJ2000,
|
225 | xyz: xyz,
|
226 | positionB1950: positionB1950,
|
227 | positionEquinox: positionEquinox
|
228 | }; |
\ | No newline at end of file |