UNPKG

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