@openwaters/almanac 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -13
- package/dist/events.js +175 -36
- package/dist/moon.js +2172 -119
- package/dist/sun.d.ts +9 -0
- package/dist/sun.js +119 -20
- package/package.json +1 -1
package/dist/sun.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { Vec3 } from './nutation.js';
|
|
2
|
+
export type VsopFormula = number[][][];
|
|
3
|
+
type VsopModel = [VsopFormula, VsopFormula, VsopFormula];
|
|
4
|
+
/**
|
|
5
|
+
* UPSTREAM: `vsop.Earth`, astronomy.ts lines 555-628 (longitude, latitude,
|
|
6
|
+
* radius). The reference the unrolled `earthLon`/`earthLat`/`earthRad`
|
|
7
|
+
* below are checked against; exported for that test only.
|
|
8
|
+
*/
|
|
9
|
+
export declare const vsopEarth: VsopModel;
|
|
2
10
|
/**
|
|
3
11
|
* UPSTREAM: `CalcVsop`, astronomy.ts lines 3255-3262, specialised to
|
|
4
12
|
* `vsop.Earth` — i.e. `HelioVector(Body.Earth, time)`. J2000 mean equator (EQJ).
|
|
@@ -25,3 +33,4 @@ export declare function sunGeoVectorEqj(tt: number): Vec3;
|
|
|
25
33
|
* @returns geocentric position in AU, true equator & equinox of date.
|
|
26
34
|
*/
|
|
27
35
|
export declare function sunGeoVector(tt: number): Vec3;
|
|
36
|
+
export {};
|
package/dist/sun.js
CHANGED
|
@@ -8,8 +8,12 @@
|
|
|
8
8
|
//
|
|
9
9
|
// INTERNAL: not part of the curated public API (see index.ts).
|
|
10
10
|
import { C_AUDAY, PI2, PrecessDirection, gyration } from './nutation.js';
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* UPSTREAM: `vsop.Earth`, astronomy.ts lines 555-628 (longitude, latitude,
|
|
13
|
+
* radius). The reference the unrolled `earthLon`/`earthLat`/`earthRad`
|
|
14
|
+
* below are checked against; exported for that test only.
|
|
15
|
+
*/
|
|
16
|
+
export const vsopEarth = [
|
|
13
17
|
[
|
|
14
18
|
[
|
|
15
19
|
[1.75347045673, 0.00000000000, 0.00000000000],
|
|
@@ -85,23 +89,118 @@ const vsopEarth = [
|
|
|
85
89
|
];
|
|
86
90
|
/** UPSTREAM: astronomy.ts lines 3229-3232. */
|
|
87
91
|
const DAYS_PER_MILLENNIUM = 365250;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
/**
|
|
93
|
+
* UPSTREAM: `VsopFormula`, astronomy.ts lines 3191-3205, written out term by
|
|
94
|
+
* term for `vsop.Earth` because the event searches evaluate it tens of
|
|
95
|
+
* thousands of times. Term order, per-series scaling, clamping and
|
|
96
|
+
* accumulation match upstream's loop, so the result is bit-for-bit the same;
|
|
97
|
+
* `test/positions.test.ts` checks that against the table above.
|
|
98
|
+
*/
|
|
99
|
+
function earthLon(t) {
|
|
93
100
|
let tpower = 1;
|
|
94
101
|
let coord = 0;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
let sum;
|
|
103
|
+
let incr;
|
|
104
|
+
sum = 0;
|
|
105
|
+
sum += 1.75347045673; // cos(0) is 1 exactly
|
|
106
|
+
sum += 0.03341656453 * Math.cos(4.66925680415 + (t * 6283.07584999140));
|
|
107
|
+
sum += 0.00034894275 * Math.cos(4.62610242189 + (t * 12566.15169998280));
|
|
108
|
+
sum += 0.00003417572 * Math.cos(2.82886579754 + (t * 3.52311834900));
|
|
109
|
+
sum += 0.00003497056 * Math.cos(2.74411783405 + (t * 5753.38488489680));
|
|
110
|
+
sum += 0.00003135899 * Math.cos(3.62767041756 + (t * 77713.77146812050));
|
|
111
|
+
sum += 0.00002676218 * Math.cos(4.41808345438 + (t * 7860.41939243920));
|
|
112
|
+
sum += 0.00002342691 * Math.cos(6.13516214446 + (t * 3930.20969621960));
|
|
113
|
+
sum += 0.00001273165 * Math.cos(2.03709657878 + (t * 529.69096509460));
|
|
114
|
+
sum += 0.00001324294 * Math.cos(0.74246341673 + (t * 11506.76976979360));
|
|
115
|
+
sum += 0.00000901854 * Math.cos(2.04505446477 + (t * 26.29831979980));
|
|
116
|
+
sum += 0.00001199167 * Math.cos(1.10962946234 + (t * 1577.34354244780));
|
|
117
|
+
sum += 0.00000857223 * Math.cos(3.50849152283 + (t * 398.14900340820));
|
|
118
|
+
sum += 0.00000779786 * Math.cos(1.17882681962 + (t * 5223.69391980220));
|
|
119
|
+
sum += 0.00000990250 * Math.cos(5.23268072088 + (t * 5884.92684658320));
|
|
120
|
+
sum += 0.00000753141 * Math.cos(2.53339052847 + (t * 5507.55323866740));
|
|
121
|
+
sum += 0.00000505267 * Math.cos(4.58292599973 + (t * 18849.22754997420));
|
|
122
|
+
sum += 0.00000492392 * Math.cos(4.20505711826 + (t * 775.52261132400));
|
|
123
|
+
sum += 0.00000356672 * Math.cos(2.91954114478 + (t * 0.06731030280));
|
|
124
|
+
sum += 0.00000284125 * Math.cos(1.89869240932 + (t * 796.29800681640));
|
|
125
|
+
sum += 0.00000242879 * Math.cos(0.34481445893 + (t * 5486.77784317500));
|
|
126
|
+
sum += 0.00000317087 * Math.cos(5.84901948512 + (t * 11790.62908865880));
|
|
127
|
+
sum += 0.00000271112 * Math.cos(0.31486255375 + (t * 10977.07880469900));
|
|
128
|
+
sum += 0.00000206217 * Math.cos(4.80646631478 + (t * 2544.31441988340));
|
|
129
|
+
sum += 0.00000205478 * Math.cos(1.86953770281 + (t * 5573.14280143310));
|
|
130
|
+
sum += 0.00000202318 * Math.cos(2.45767790232 + (t * 6069.77675455340));
|
|
131
|
+
sum += 0.00000126225 * Math.cos(1.08295459501 + (t * 20.77539549240));
|
|
132
|
+
sum += 0.00000155516 * Math.cos(0.83306084617 + (t * 213.29909543800));
|
|
133
|
+
incr = tpower * sum;
|
|
134
|
+
incr %= PI2;
|
|
135
|
+
coord += incr;
|
|
136
|
+
tpower *= t;
|
|
137
|
+
sum = 0;
|
|
138
|
+
sum += 6283.07584999140; // cos(0) is 1 exactly
|
|
139
|
+
sum += 0.00206058863 * Math.cos(2.67823455808 + (t * 6283.07584999140));
|
|
140
|
+
sum += 0.00004303419 * Math.cos(2.63512233481 + (t * 12566.15169998280));
|
|
141
|
+
incr = tpower * sum;
|
|
142
|
+
incr %= PI2;
|
|
143
|
+
coord += incr;
|
|
144
|
+
tpower *= t;
|
|
145
|
+
sum = 0;
|
|
146
|
+
sum += 0.00008721859 * Math.cos(1.07253635559 + (t * 6283.07584999140));
|
|
147
|
+
incr = tpower * sum;
|
|
148
|
+
incr %= PI2;
|
|
149
|
+
coord += incr;
|
|
150
|
+
tpower *= t;
|
|
151
|
+
return coord;
|
|
152
|
+
}
|
|
153
|
+
function earthLat(t) {
|
|
154
|
+
let tpower = 1;
|
|
155
|
+
let coord = 0;
|
|
156
|
+
let sum;
|
|
157
|
+
let incr;
|
|
158
|
+
sum = 0;
|
|
159
|
+
incr = tpower * sum;
|
|
160
|
+
coord += incr;
|
|
161
|
+
tpower *= t;
|
|
162
|
+
sum = 0;
|
|
163
|
+
sum += 0.00227777722 * Math.cos(3.41376620530 + (t * 6283.07584999140));
|
|
164
|
+
sum += 0.00003805678 * Math.cos(3.37063423795 + (t * 12566.15169998280));
|
|
165
|
+
incr = tpower * sum;
|
|
166
|
+
coord += incr;
|
|
167
|
+
tpower *= t;
|
|
168
|
+
return coord;
|
|
169
|
+
}
|
|
170
|
+
function earthRad(t) {
|
|
171
|
+
let tpower = 1;
|
|
172
|
+
let coord = 0;
|
|
173
|
+
let sum;
|
|
174
|
+
let incr;
|
|
175
|
+
sum = 0;
|
|
176
|
+
sum += 1.00013988784; // cos(0) is 1 exactly
|
|
177
|
+
sum += 0.01670699632 * Math.cos(3.09846350258 + (t * 6283.07584999140));
|
|
178
|
+
sum += 0.00013956024 * Math.cos(3.05524609456 + (t * 12566.15169998280));
|
|
179
|
+
sum += 0.00003083720 * Math.cos(5.19846674381 + (t * 77713.77146812050));
|
|
180
|
+
sum += 0.00001628463 * Math.cos(1.17387558054 + (t * 5753.38488489680));
|
|
181
|
+
sum += 0.00001575572 * Math.cos(2.84685214877 + (t * 7860.41939243920));
|
|
182
|
+
sum += 0.00000924799 * Math.cos(5.45292236722 + (t * 11506.76976979360));
|
|
183
|
+
sum += 0.00000542439 * Math.cos(4.56409151453 + (t * 3930.20969621960));
|
|
184
|
+
sum += 0.00000472110 * Math.cos(3.66100022149 + (t * 5884.92684658320));
|
|
185
|
+
sum += 0.00000085831 * Math.cos(1.27079125277 + (t * 161000.68573767410));
|
|
186
|
+
sum += 0.00000057056 * Math.cos(2.01374292245 + (t * 83996.84731811189));
|
|
187
|
+
sum += 0.00000055736 * Math.cos(5.24159799170 + (t * 71430.69561812909));
|
|
188
|
+
sum += 0.00000174844 * Math.cos(3.01193636733 + (t * 18849.22754997420));
|
|
189
|
+
sum += 0.00000243181 * Math.cos(4.27349530790 + (t * 11790.62908865880));
|
|
190
|
+
incr = tpower * sum;
|
|
191
|
+
coord += incr;
|
|
192
|
+
tpower *= t;
|
|
193
|
+
sum = 0;
|
|
194
|
+
sum += 0.00103018607 * Math.cos(1.10748968172 + (t * 6283.07584999140));
|
|
195
|
+
sum += 0.00001721238 * Math.cos(1.06442300386 + (t * 12566.15169998280));
|
|
196
|
+
incr = tpower * sum;
|
|
197
|
+
coord += incr;
|
|
198
|
+
tpower *= t;
|
|
199
|
+
sum = 0;
|
|
200
|
+
sum += 0.00004359385 * Math.cos(5.78455133808 + (t * 6283.07584999140));
|
|
201
|
+
incr = tpower * sum;
|
|
202
|
+
coord += incr;
|
|
203
|
+
tpower *= t;
|
|
105
204
|
return coord;
|
|
106
205
|
}
|
|
107
206
|
/** UPSTREAM: `VsopRotate`, astronomy.ts lines 3234-3241 — VSOP ecliptic to J2000 equatorial. */
|
|
@@ -130,9 +229,9 @@ function vsopSphereToRect(lon, lat, radius) {
|
|
|
130
229
|
*/
|
|
131
230
|
export function earthHelioVector(tt) {
|
|
132
231
|
const t = tt / DAYS_PER_MILLENNIUM; // millennia since 2000
|
|
133
|
-
const lon =
|
|
134
|
-
const lat =
|
|
135
|
-
const rad =
|
|
232
|
+
const lon = earthLon(t);
|
|
233
|
+
const lat = earthLat(t);
|
|
234
|
+
const rad = earthRad(t);
|
|
136
235
|
const eclip = vsopSphereToRect(lon, lat, rad);
|
|
137
236
|
return vsopRotate(eclip);
|
|
138
237
|
}
|