@zodiacs/engine 0.1.1-rc.14
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/CHANGELOG.md +502 -0
- package/LICENSE +21 -0
- package/LICENSING.md +99 -0
- package/NOTICE +58 -0
- package/README.md +785 -0
- package/dist/chunk-4OSOCZY2.js +340 -0
- package/dist/chunk-AECKV73C.js +231 -0
- package/dist/chunk-CPALRSPC.js +35 -0
- package/dist/chunk-GFT24GFR.js +25 -0
- package/dist/chunk-NAJ735VN.js +219 -0
- package/dist/chunk-ONBZ4HK7.js +285 -0
- package/dist/chunk-PFGUCNOK.js +87 -0
- package/dist/chunk-RETEVD4F.js +681 -0
- package/dist/crossings.d.ts +91 -0
- package/dist/crossings.js +8 -0
- package/dist/deltat.d.ts +73 -0
- package/dist/deltat.js +12 -0
- package/dist/geo.d.ts +58 -0
- package/dist/geo.js +312 -0
- package/dist/index.d.ts +478 -0
- package/dist/index.js +682 -0
- package/dist/internal-math-BE2hcSHd.d.ts +271 -0
- package/dist/internal-math.d.ts +3 -0
- package/dist/internal-math.js +76 -0
- package/dist/internal.d.ts +9 -0
- package/dist/internal.js +16 -0
- package/dist/receipt.d.ts +224 -0
- package/dist/receipt.js +824 -0
- package/dist/types-CeafogFp.d.ts +197 -0
- package/package.json +94 -0
|
@@ -0,0 +1,681 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computeAngles,
|
|
3
|
+
computeHouses,
|
|
4
|
+
eastPointOf,
|
|
5
|
+
vertexOf
|
|
6
|
+
} from "./chunk-4OSOCZY2.js";
|
|
7
|
+
import {
|
|
8
|
+
EPHEMERIS_SPAN,
|
|
9
|
+
outsideReferenceSpan
|
|
10
|
+
} from "./chunk-GFT24GFR.js";
|
|
11
|
+
import {
|
|
12
|
+
deltaT,
|
|
13
|
+
deltaTAt
|
|
14
|
+
} from "./chunk-ONBZ4HK7.js";
|
|
15
|
+
import {
|
|
16
|
+
ENGINE_VERSION,
|
|
17
|
+
degreeInSign,
|
|
18
|
+
findAspects,
|
|
19
|
+
normalizeLongitude,
|
|
20
|
+
signForLongitude
|
|
21
|
+
} from "./chunk-NAJ735VN.js";
|
|
22
|
+
|
|
23
|
+
// src/body-label.ts
|
|
24
|
+
var MAX_BODY_LABEL_LENGTH = 80;
|
|
25
|
+
function checkedBodyLabel(value) {
|
|
26
|
+
if (typeof value !== "string" || value.length === 0 || value.length > MAX_BODY_LABEL_LENGTH || value.trim() !== value || /[\u0000-\u001f\u007f]/u.test(value)) {
|
|
27
|
+
throw new RangeError(
|
|
28
|
+
"Body labels must be nonempty, trimmed strings of at most 80 characters, without control characters."
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/exact.ts
|
|
35
|
+
var SAFE_MAGNITUDE = 2 ** 1e3;
|
|
36
|
+
function add(partials, value) {
|
|
37
|
+
let x = value;
|
|
38
|
+
let kept = 0;
|
|
39
|
+
for (let index = 0; index < partials.length; index += 1) {
|
|
40
|
+
let y = partials[index];
|
|
41
|
+
if (Math.abs(x) < Math.abs(y)) {
|
|
42
|
+
const larger = y;
|
|
43
|
+
y = x;
|
|
44
|
+
x = larger;
|
|
45
|
+
}
|
|
46
|
+
const high = x + y;
|
|
47
|
+
const low = y - (high - x);
|
|
48
|
+
if (low !== 0) partials[kept++] = low;
|
|
49
|
+
x = high;
|
|
50
|
+
}
|
|
51
|
+
partials.length = kept;
|
|
52
|
+
if (x !== 0) partials.push(x);
|
|
53
|
+
}
|
|
54
|
+
function exactSum(...terms) {
|
|
55
|
+
const partials = [];
|
|
56
|
+
for (const term of terms) {
|
|
57
|
+
if (typeof term === "number") add(partials, term);
|
|
58
|
+
else for (const part of term) add(partials, part);
|
|
59
|
+
}
|
|
60
|
+
return partials;
|
|
61
|
+
}
|
|
62
|
+
function negated(sum) {
|
|
63
|
+
return sum.map((part) => -part);
|
|
64
|
+
}
|
|
65
|
+
function signOf(sum) {
|
|
66
|
+
const top = sum[sum.length - 1];
|
|
67
|
+
return top === void 0 ? 0 : top > 0 ? 1 : -1;
|
|
68
|
+
}
|
|
69
|
+
function compareExact(a, b) {
|
|
70
|
+
return signOf(exactSum(a, typeof b === "number" ? -b : negated(b)));
|
|
71
|
+
}
|
|
72
|
+
function absolute(sum) {
|
|
73
|
+
return signOf(sum) < 0 ? negated(sum) : sum;
|
|
74
|
+
}
|
|
75
|
+
function roundedValue(sum) {
|
|
76
|
+
let index = sum.length;
|
|
77
|
+
if (index === 0) return 0;
|
|
78
|
+
let high = sum[--index];
|
|
79
|
+
let low = 0;
|
|
80
|
+
while (index > 0) {
|
|
81
|
+
const x = high;
|
|
82
|
+
const y = sum[--index];
|
|
83
|
+
high = x + y;
|
|
84
|
+
low = y - (high - x);
|
|
85
|
+
if (low !== 0) break;
|
|
86
|
+
}
|
|
87
|
+
const below = index > 0 ? sum[index - 1] : 0;
|
|
88
|
+
if (low < 0 && below < 0 || low > 0 && below > 0) {
|
|
89
|
+
const twice = low * 2;
|
|
90
|
+
const moved = high + twice;
|
|
91
|
+
if (moved - high === twice) high = moved;
|
|
92
|
+
}
|
|
93
|
+
return high;
|
|
94
|
+
}
|
|
95
|
+
function scaledInteger(value) {
|
|
96
|
+
const view = new DataView(new ArrayBuffer(8));
|
|
97
|
+
view.setFloat64(0, value);
|
|
98
|
+
const upper = view.getUint32(0);
|
|
99
|
+
const exponent = upper >>> 20 & 2047;
|
|
100
|
+
let significand = BigInt(upper & 1048575) << 32n | BigInt(view.getUint32(4));
|
|
101
|
+
if (exponent !== 0) significand = (significand | 1n << 52n) << BigInt(exponent - 1);
|
|
102
|
+
return upper >>> 31 === 1 ? -significand : significand;
|
|
103
|
+
}
|
|
104
|
+
function exactSign(terms) {
|
|
105
|
+
if (terms.every((term) => Math.abs(term) < SAFE_MAGNITUDE)) return signOf(exactSum(...terms));
|
|
106
|
+
let total = 0n;
|
|
107
|
+
for (const term of terms) total += scaledInteger(term);
|
|
108
|
+
return total > 0n ? 1 : total < 0n ? -1 : 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// src/declination.ts
|
|
112
|
+
var DEG = Math.PI / 180;
|
|
113
|
+
var RAD = 180 / Math.PI;
|
|
114
|
+
var DECLINATION_ORB = 1;
|
|
115
|
+
var DECLINATION_ORB_LUMINARY = 1.5;
|
|
116
|
+
var DEFAULT_DECLINATION_ORB_POLICY = Object.freeze({
|
|
117
|
+
orb: DECLINATION_ORB,
|
|
118
|
+
luminaryOrb: DECLINATION_ORB_LUMINARY
|
|
119
|
+
});
|
|
120
|
+
var RA_POLE_TOLERANCE = 32 * Number.EPSILON;
|
|
121
|
+
var MAX_DECLINATION_BODIES = 256;
|
|
122
|
+
var SUN_BOUND_LATITUDE = 1e-3;
|
|
123
|
+
function finite(value, label) {
|
|
124
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
125
|
+
throw new RangeError(`${label} must be finite.`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function obliquity(value) {
|
|
129
|
+
finite(value, "true obliquity");
|
|
130
|
+
if (value < 0 || value > 90) throw new RangeError("true obliquity must be in [0,90] degrees.");
|
|
131
|
+
}
|
|
132
|
+
function normalize(value) {
|
|
133
|
+
const remainder = value % 360;
|
|
134
|
+
if (remainder === 0) return 0;
|
|
135
|
+
return remainder > 0 ? remainder : Math.min(remainder + 360, 359.99999999999994);
|
|
136
|
+
}
|
|
137
|
+
function policyOf(policy) {
|
|
138
|
+
const fields = dataFields(policy, "declination orb policy");
|
|
139
|
+
if (Object.keys(fields).length !== 2 || !Object.hasOwn(fields, "orb") || !Object.hasOwn(fields, "luminaryOrb")) {
|
|
140
|
+
throw new RangeError("declination orb policy requires only orb and luminaryOrb.");
|
|
141
|
+
}
|
|
142
|
+
const checked = { orb: fields.orb.value, luminaryOrb: fields.luminaryOrb.value };
|
|
143
|
+
for (const key of ["orb", "luminaryOrb"]) {
|
|
144
|
+
finite(checked[key], `declination policy ${key}`);
|
|
145
|
+
if (checked[key] < 0 || checked[key] > 90) throw new RangeError("declination orbs must be in [0,90] degrees.");
|
|
146
|
+
}
|
|
147
|
+
return checked;
|
|
148
|
+
}
|
|
149
|
+
function dataFields(value, label) {
|
|
150
|
+
if (value === null || typeof value !== "object" || Array.isArray(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) {
|
|
151
|
+
throw new RangeError(`${label} must be a plain data object.`);
|
|
152
|
+
}
|
|
153
|
+
const fields = Object.getOwnPropertyDescriptors(value);
|
|
154
|
+
if (Reflect.ownKeys(value).length !== Object.keys(fields).length || Object.values(fields).some((field) => !Object.hasOwn(field, "value") || !field.enumerable)) {
|
|
155
|
+
throw new RangeError(`${label} must contain only enumerable data properties.`);
|
|
156
|
+
}
|
|
157
|
+
return fields;
|
|
158
|
+
}
|
|
159
|
+
function bodyName(body) {
|
|
160
|
+
checkedBodyLabel(body);
|
|
161
|
+
}
|
|
162
|
+
function eclipticToEquatorial(longitudeDeg, latitudeDeg, trueObliquityDeg) {
|
|
163
|
+
finite(longitudeDeg, "ecliptic longitude");
|
|
164
|
+
finite(latitudeDeg, "ecliptic latitude");
|
|
165
|
+
if (latitudeDeg < -90 || latitudeDeg > 90) throw new RangeError("ecliptic latitude must be in [-90,90] degrees.");
|
|
166
|
+
obliquity(trueObliquityDeg);
|
|
167
|
+
const lon = normalize(longitudeDeg) * DEG;
|
|
168
|
+
const lat = latitudeDeg * DEG;
|
|
169
|
+
const tilt = trueObliquityDeg * DEG;
|
|
170
|
+
const cosLat = Math.cos(lat);
|
|
171
|
+
const x = cosLat * Math.cos(lon);
|
|
172
|
+
const y = cosLat * Math.sin(lon) * Math.cos(tilt) - Math.sin(lat) * Math.sin(tilt);
|
|
173
|
+
const z = cosLat * Math.sin(lon) * Math.sin(tilt) + Math.sin(lat) * Math.cos(tilt);
|
|
174
|
+
const horizontal = Math.hypot(x, y);
|
|
175
|
+
const raDefined = horizontal > RA_POLE_TOLERANCE;
|
|
176
|
+
let dec = trueObliquityDeg === 0 ? latitudeDeg : Math.atan2(z, horizontal) * RAD;
|
|
177
|
+
if (latitudeDeg === 0) dec = Math.max(-trueObliquityDeg, Math.min(trueObliquityDeg, dec));
|
|
178
|
+
return {
|
|
179
|
+
ra: raDefined ? trueObliquityDeg === 0 ? normalize(longitudeDeg) : normalize(Math.atan2(y, x) * RAD) : null,
|
|
180
|
+
dec: dec === 0 ? 0 : dec,
|
|
181
|
+
raDefined
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function declinationOf(lon, lat, trueObliquity) {
|
|
185
|
+
return eclipticToEquatorial(lon, lat, trueObliquity).dec;
|
|
186
|
+
}
|
|
187
|
+
function declinationOrb(a, b, policy = DEFAULT_DECLINATION_ORB_POLICY) {
|
|
188
|
+
bodyName(a);
|
|
189
|
+
bodyName(b);
|
|
190
|
+
const checked = policyOf(policy);
|
|
191
|
+
return a === "Sun" || a === "Moon" || b === "Sun" || b === "Moon" ? checked.luminaryOrb : checked.orb;
|
|
192
|
+
}
|
|
193
|
+
function placeBodies(bodies, trueObliquity, chartSun = false) {
|
|
194
|
+
obliquity(trueObliquity);
|
|
195
|
+
if (!Array.isArray(bodies) || Object.getPrototypeOf(bodies) !== Array.prototype) {
|
|
196
|
+
throw new RangeError("declination bodies must be a standard array.");
|
|
197
|
+
}
|
|
198
|
+
const fields = Object.getOwnPropertyDescriptors(bodies);
|
|
199
|
+
const length = fields.length.value;
|
|
200
|
+
if (length > MAX_DECLINATION_BODIES || Reflect.ownKeys(bodies).length !== length + 1) {
|
|
201
|
+
throw new RangeError("declination bodies must be dense, undecorated, and contain at most 256 entries.");
|
|
202
|
+
}
|
|
203
|
+
const seen = /* @__PURE__ */ new Set();
|
|
204
|
+
const placed = [];
|
|
205
|
+
const longitudes = [];
|
|
206
|
+
for (let index = 0; index < length; index += 1) {
|
|
207
|
+
const field = fields[String(index)];
|
|
208
|
+
if (!field || !Object.hasOwn(field, "value") || !field.enumerable) {
|
|
209
|
+
throw new RangeError("declination bodies must contain only enumerable data entries.");
|
|
210
|
+
}
|
|
211
|
+
const source = dataFields(field.value, "declination body");
|
|
212
|
+
const body = { body: source.body?.value, lon: source.lon?.value, lat: source.lat?.value };
|
|
213
|
+
bodyName(body.body);
|
|
214
|
+
if (seen.has(body.body)) throw new RangeError("duplicate declination body identifier.");
|
|
215
|
+
seen.add(body.body);
|
|
216
|
+
const position2 = eclipticToEquatorial(body.lon, body.lat, trueObliquity);
|
|
217
|
+
const exemptSun = body.body === "Sun" && (chartSun || Math.abs(body.lat) <= SUN_BOUND_LATITUDE);
|
|
218
|
+
placed.push({
|
|
219
|
+
body: body.body,
|
|
220
|
+
lon: normalize(body.lon),
|
|
221
|
+
lat: body.lat,
|
|
222
|
+
...position2,
|
|
223
|
+
outOfBounds: !exemptSun && Math.abs(position2.dec) > trueObliquity,
|
|
224
|
+
boundMarginArcsec: (Math.abs(position2.dec) - trueObliquity) * 3600
|
|
225
|
+
});
|
|
226
|
+
longitudes.push(body.lon);
|
|
227
|
+
}
|
|
228
|
+
return { rows: placed, longitudes };
|
|
229
|
+
}
|
|
230
|
+
function longitudeSeparation(a, b) {
|
|
231
|
+
let difference = exactSum(a % 360, -(b % 360));
|
|
232
|
+
while (signOf(difference) < 0) difference = exactSum(difference, 360);
|
|
233
|
+
while (compareExact(difference, 360) >= 0) difference = exactSum(difference, -360);
|
|
234
|
+
return roundedValue(compareExact(difference, 180) > 0 ? exactSum(360, negated(difference)) : difference);
|
|
235
|
+
}
|
|
236
|
+
function aspectsFor({ rows, longitudes }, policy) {
|
|
237
|
+
const found = [];
|
|
238
|
+
for (let i = 0; i < rows.length; i += 1) {
|
|
239
|
+
for (let j = i + 1; j < rows.length; j += 1) {
|
|
240
|
+
const a = rows[i];
|
|
241
|
+
const b = rows[j];
|
|
242
|
+
const parallel = absolute(exactSum(a.dec, -b.dec));
|
|
243
|
+
const contraparallel = absolute(exactSum(a.dec, b.dec));
|
|
244
|
+
const isParallel = compareExact(parallel, contraparallel) <= 0;
|
|
245
|
+
const exactOrb = isParallel ? parallel : contraparallel;
|
|
246
|
+
const maximumOrb = declinationOrb(a.body, b.body, policy);
|
|
247
|
+
if (compareExact(exactOrb, maximumOrb) > 0) continue;
|
|
248
|
+
found.push({ exactOrb, aspect: {
|
|
249
|
+
a: a.body,
|
|
250
|
+
b: b.body,
|
|
251
|
+
type: isParallel ? "parallel" : "contraparallel",
|
|
252
|
+
orb: roundedValue(exactOrb),
|
|
253
|
+
maximumOrb,
|
|
254
|
+
decA: a.dec,
|
|
255
|
+
decB: b.dec,
|
|
256
|
+
separation: longitudeSeparation(longitudes[i], longitudes[j])
|
|
257
|
+
} });
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return found.sort((x, y) => compareExact(x.exactOrb, y.exactOrb)).map((entry) => entry.aspect);
|
|
261
|
+
}
|
|
262
|
+
function findDeclinationAspects(bodies, trueObliquity, policy = DEFAULT_DECLINATION_ORB_POLICY) {
|
|
263
|
+
const checked = policyOf(policy);
|
|
264
|
+
return aspectsFor(placeBodies(bodies, trueObliquity), checked);
|
|
265
|
+
}
|
|
266
|
+
function declinations(bodies, trueObliquity, policy, chartSun) {
|
|
267
|
+
const checked = policyOf(policy);
|
|
268
|
+
const placed = placeBodies(bodies, trueObliquity, chartSun);
|
|
269
|
+
return {
|
|
270
|
+
trueObliquity,
|
|
271
|
+
rows: placed.rows,
|
|
272
|
+
aspects: aspectsFor(placed, checked),
|
|
273
|
+
orbPolicy: checked,
|
|
274
|
+
convention: "true-equator-and-equinox-of-date; full-ecliptic-longitude-and-latitude",
|
|
275
|
+
receiptScope: "not-included-in-natal-receipt"
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
function declinationsForBodies(bodies, trueObliquity, policy = DEFAULT_DECLINATION_ORB_POLICY) {
|
|
279
|
+
return declinations(bodies, trueObliquity, policy, false);
|
|
280
|
+
}
|
|
281
|
+
function chartBodyDeclinations(bodies, trueObliquity) {
|
|
282
|
+
return declinations(bodies, trueObliquity, DEFAULT_DECLINATION_ORB_POLICY, true);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// src/points.ts
|
|
286
|
+
var DEG2 = Math.PI / 180;
|
|
287
|
+
var RAD2 = 180 / Math.PI;
|
|
288
|
+
var ARCSEC = 1 / 3600;
|
|
289
|
+
function lunarMeanArguments(centuries) {
|
|
290
|
+
const t = centuries;
|
|
291
|
+
const l = 485868.249036 + t * (17179159232178e-4 + t * (31.8792 + t * (0.051635 + t * -2447e-7)));
|
|
292
|
+
const F = 335779.526232 + t * (17395272628478e-4 + t * (-12.7512 + t * (-1037e-6 + t * 417e-8)));
|
|
293
|
+
const node = 450160.398036 + t * (-69628905431e-4 + t * (7.4722 + t * (7702e-6 + t * -5939e-8)));
|
|
294
|
+
return { l: l * ARCSEC, F: F * ARCSEC, node: node * ARCSEC };
|
|
295
|
+
}
|
|
296
|
+
var MEAN_LUNAR_INCLINATION = 5.1453964;
|
|
297
|
+
function meanNodeLongitude(centuries, nutation) {
|
|
298
|
+
return normalizeLongitude(lunarMeanArguments(centuries).node + nutation);
|
|
299
|
+
}
|
|
300
|
+
function meanApogee(centuries, nutation) {
|
|
301
|
+
const { l, F, node } = lunarMeanArguments(centuries);
|
|
302
|
+
const u = (F - l + 180) * DEG2;
|
|
303
|
+
const i = MEAN_LUNAR_INCLINATION * DEG2;
|
|
304
|
+
const lon = node + Math.atan2(Math.cos(i) * Math.sin(u), Math.cos(u)) * RAD2 + nutation;
|
|
305
|
+
return { lon: normalizeLongitude(lon), lat: Math.asin(Math.sin(i) * Math.sin(u)) * RAD2 };
|
|
306
|
+
}
|
|
307
|
+
function sectOf(ascendant, sun) {
|
|
308
|
+
return normalizeLongitude(sun - ascendant) >= 180 ? "day" : "night";
|
|
309
|
+
}
|
|
310
|
+
var LOTS = [
|
|
311
|
+
"Lot of Fortune",
|
|
312
|
+
"Lot of Spirit",
|
|
313
|
+
"Lot of Eros",
|
|
314
|
+
"Lot of Necessity",
|
|
315
|
+
"Lot of Courage",
|
|
316
|
+
"Lot of Victory",
|
|
317
|
+
"Lot of Nemesis"
|
|
318
|
+
];
|
|
319
|
+
function hellenisticLots(inputs, sect) {
|
|
320
|
+
const lot = (from, to) => normalizeLongitude(inputs.ascendant + (sect === "day" ? to - from : from - to));
|
|
321
|
+
const fortune = lot(inputs.sun, inputs.moon);
|
|
322
|
+
const spirit = lot(inputs.moon, inputs.sun);
|
|
323
|
+
return [
|
|
324
|
+
{ point: "Lot of Fortune", lon: fortune },
|
|
325
|
+
{ point: "Lot of Spirit", lon: spirit },
|
|
326
|
+
{ point: "Lot of Eros", lon: lot(spirit, inputs.venus) },
|
|
327
|
+
{ point: "Lot of Necessity", lon: lot(inputs.mercury, fortune) },
|
|
328
|
+
{ point: "Lot of Courage", lon: lot(inputs.mars, fortune) },
|
|
329
|
+
{ point: "Lot of Victory", lon: lot(spirit, inputs.jupiter) },
|
|
330
|
+
{ point: "Lot of Nemesis", lon: lot(inputs.saturn, fortune) }
|
|
331
|
+
];
|
|
332
|
+
}
|
|
333
|
+
function antiscion(longitude) {
|
|
334
|
+
return normalizeLongitude(180 - longitude);
|
|
335
|
+
}
|
|
336
|
+
function contraAntiscion(longitude) {
|
|
337
|
+
return normalizeLongitude(-longitude);
|
|
338
|
+
}
|
|
339
|
+
function midpoint(first, second) {
|
|
340
|
+
const arc = normalizeLongitude(second - first);
|
|
341
|
+
return normalizeLongitude(first + (arc > 180 ? arc - 360 : arc) / 2);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// src/ephemeris.ts
|
|
345
|
+
import {
|
|
346
|
+
Body,
|
|
347
|
+
EclipticGeoMoon,
|
|
348
|
+
GeoMoonState,
|
|
349
|
+
GeoVector,
|
|
350
|
+
MakeTime,
|
|
351
|
+
RotateVector,
|
|
352
|
+
Rotation_EQJ_ECT,
|
|
353
|
+
SetDeltaTFunction,
|
|
354
|
+
SiderealTime,
|
|
355
|
+
Vector,
|
|
356
|
+
e_tilt
|
|
357
|
+
} from "astronomy-engine";
|
|
358
|
+
var RAD3 = 180 / Math.PI;
|
|
359
|
+
var J2000_MS = Date.UTC(2e3, 0, 1, 12);
|
|
360
|
+
function clock(pin) {
|
|
361
|
+
SetDeltaTFunction(pin === void 0 ? deltaT : () => pin);
|
|
362
|
+
}
|
|
363
|
+
function evaluated(run) {
|
|
364
|
+
try {
|
|
365
|
+
return run();
|
|
366
|
+
} catch (thrown) {
|
|
367
|
+
if (thrown instanceof Error) throw thrown;
|
|
368
|
+
throw new RangeError(`The ephemeris could not evaluate this instant: ${String(thrown)}`, { cause: thrown });
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
function timeOf(date) {
|
|
372
|
+
const time = Number.isFinite(date.getTime()) ? MakeTime(date) : null;
|
|
373
|
+
const { from, to } = EPHEMERIS_SPAN.daysFromJ2000;
|
|
374
|
+
if (!(time !== null && time.tt >= from && time.tt <= to)) {
|
|
375
|
+
throw new RangeError(
|
|
376
|
+
"The instant is outside the ephemeris span: its Terrestrial Time, and that of each speed sample, must lie between 0001-04-30T12:00 and 3998-09-03T12:00 TT, the years astronomy-engine tabulates (EPHEMERIS_SPAN)."
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
return time;
|
|
380
|
+
}
|
|
381
|
+
function sampleDate(date, stepDays) {
|
|
382
|
+
return new Date(date.getTime() + stepDays * 864e5);
|
|
383
|
+
}
|
|
384
|
+
function deltaTFor(date, pin) {
|
|
385
|
+
if (pin !== void 0) {
|
|
386
|
+
return { seconds: pin, sigma: null, model: "pinned", table: null, tableDigest: null, segment: "pinned" };
|
|
387
|
+
}
|
|
388
|
+
return deltaTAt((date.getTime() - J2000_MS) / 864e5);
|
|
389
|
+
}
|
|
390
|
+
var PLANETS = [
|
|
391
|
+
{ name: "Sun", body: Body.Sun },
|
|
392
|
+
{ name: "Mercury", body: Body.Mercury },
|
|
393
|
+
{ name: "Venus", body: Body.Venus },
|
|
394
|
+
{ name: "Mars", body: Body.Mars },
|
|
395
|
+
{ name: "Jupiter", body: Body.Jupiter },
|
|
396
|
+
{ name: "Saturn", body: Body.Saturn },
|
|
397
|
+
{ name: "Uranus", body: Body.Uranus },
|
|
398
|
+
{ name: "Neptune", body: Body.Neptune },
|
|
399
|
+
{ name: "Pluto", body: Body.Pluto }
|
|
400
|
+
];
|
|
401
|
+
function eclipticOfDate(body, date) {
|
|
402
|
+
const time = timeOf(date);
|
|
403
|
+
const equatorial = GeoVector(body, time, true);
|
|
404
|
+
const ecliptic = RotateVector(Rotation_EQJ_ECT(time), equatorial);
|
|
405
|
+
const lon = normalizeLongitude(Math.atan2(ecliptic.y, ecliptic.x) * RAD3);
|
|
406
|
+
const lat = Math.asin(ecliptic.z / Math.hypot(ecliptic.x, ecliptic.y, ecliptic.z)) * RAD3;
|
|
407
|
+
return { lon, lat };
|
|
408
|
+
}
|
|
409
|
+
function moonOfDate(date) {
|
|
410
|
+
const moon = EclipticGeoMoon(timeOf(date));
|
|
411
|
+
return { lon: normalizeLongitude(moon.lon), lat: moon.lat };
|
|
412
|
+
}
|
|
413
|
+
function trueNodeLongitude(date) {
|
|
414
|
+
const time = timeOf(date);
|
|
415
|
+
const state = GeoMoonState(time);
|
|
416
|
+
const angularMomentum = {
|
|
417
|
+
x: state.y * state.vz - state.z * state.vy,
|
|
418
|
+
y: state.z * state.vx - state.x * state.vz,
|
|
419
|
+
z: state.x * state.vy - state.y * state.vx
|
|
420
|
+
};
|
|
421
|
+
const eclipticMomentum = RotateVector(
|
|
422
|
+
Rotation_EQJ_ECT(time),
|
|
423
|
+
new Vector(angularMomentum.x, angularMomentum.y, angularMomentum.z, time)
|
|
424
|
+
);
|
|
425
|
+
return normalizeLongitude(Math.atan2(eclipticMomentum.x, -eclipticMomentum.y) * RAD3);
|
|
426
|
+
}
|
|
427
|
+
function longitudeAt(body, date) {
|
|
428
|
+
if (body === "Moon") return moonOfDate(date).lon;
|
|
429
|
+
if (body === "North Node") return trueNodeLongitude(date);
|
|
430
|
+
if (body === "South Node") {
|
|
431
|
+
return normalizeLongitude(trueNodeLongitude(date) + 180);
|
|
432
|
+
}
|
|
433
|
+
const planet = PLANETS.find((candidate) => candidate.name === body);
|
|
434
|
+
if (!planet) throw new RangeError(`Unknown body: ${body}`);
|
|
435
|
+
return eclipticOfDate(planet.body, date).lon;
|
|
436
|
+
}
|
|
437
|
+
function bodyLongitude(body, date) {
|
|
438
|
+
return evaluated(() => {
|
|
439
|
+
clock();
|
|
440
|
+
return longitudeAt(body, date);
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
var SPEED_STEP_DAYS = 1e-3;
|
|
444
|
+
var NODE_SPEED_STEP_DAYS = 0.25;
|
|
445
|
+
function longitudeSpeed(body, date) {
|
|
446
|
+
return evaluated(() => {
|
|
447
|
+
clock();
|
|
448
|
+
return speedAt(body, date);
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
function speedAt(body, date) {
|
|
452
|
+
const stepDays = body === "North Node" || body === "South Node" ? NODE_SPEED_STEP_DAYS : SPEED_STEP_DAYS;
|
|
453
|
+
const before = longitudeAt(body, sampleDate(date, -stepDays));
|
|
454
|
+
const after = longitudeAt(body, sampleDate(date, stepDays));
|
|
455
|
+
let difference = after - before;
|
|
456
|
+
if (difference > 180) difference -= 360;
|
|
457
|
+
if (difference < -180) difference += 360;
|
|
458
|
+
return difference / (2 * stepDays);
|
|
459
|
+
}
|
|
460
|
+
function position(body, lon, lat, speed) {
|
|
461
|
+
return {
|
|
462
|
+
body,
|
|
463
|
+
lon,
|
|
464
|
+
lat,
|
|
465
|
+
speed,
|
|
466
|
+
retrograde: speed < 0,
|
|
467
|
+
sign: signForLongitude(lon).slug,
|
|
468
|
+
degree: degreeInSign(lon)
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
function computeBodies(date) {
|
|
472
|
+
return evaluated(() => {
|
|
473
|
+
clock();
|
|
474
|
+
return bodiesAt(date);
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
function bodiesAt(date) {
|
|
478
|
+
const bodies = [];
|
|
479
|
+
for (const planet of PLANETS) {
|
|
480
|
+
const coordinates = eclipticOfDate(planet.body, date);
|
|
481
|
+
bodies.push(
|
|
482
|
+
position(planet.name, coordinates.lon, coordinates.lat, speedAt(planet.name, date))
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
const moon = moonOfDate(date);
|
|
486
|
+
bodies.splice(1, 0, position("Moon", moon.lon, moon.lat, speedAt("Moon", date)));
|
|
487
|
+
const northNode = trueNodeLongitude(date);
|
|
488
|
+
const nodeSpeed = speedAt("North Node", date);
|
|
489
|
+
bodies.push(
|
|
490
|
+
position("North Node", northNode, 0, nodeSpeed),
|
|
491
|
+
position("South Node", normalizeLongitude(northNode + 180), 0, nodeSpeed)
|
|
492
|
+
);
|
|
493
|
+
return bodies;
|
|
494
|
+
}
|
|
495
|
+
function computeChart(input) {
|
|
496
|
+
const pin = input.deltaT;
|
|
497
|
+
return evaluated(() => {
|
|
498
|
+
clock(pin);
|
|
499
|
+
try {
|
|
500
|
+
return chartAt(input, pin);
|
|
501
|
+
} finally {
|
|
502
|
+
if (pin !== void 0) clock();
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
function chartAt(input, pin) {
|
|
507
|
+
const flags = [...input.flags ?? []];
|
|
508
|
+
const bodies = bodiesAt(input.utc);
|
|
509
|
+
let angles = null;
|
|
510
|
+
let houses = null;
|
|
511
|
+
if (input.timeKnown && input.latitude !== void 0 && input.longitude !== void 0) {
|
|
512
|
+
const time = timeOf(input.utc);
|
|
513
|
+
const angleInput = {
|
|
514
|
+
gastHours: SiderealTime(time),
|
|
515
|
+
latitude: input.latitude,
|
|
516
|
+
longitude: input.longitude,
|
|
517
|
+
obliquity: e_tilt(time).tobl
|
|
518
|
+
};
|
|
519
|
+
angles = computeAngles(angleInput);
|
|
520
|
+
const result = computeHouses(input.houseSystem, angleInput, angles);
|
|
521
|
+
houses = result.houses;
|
|
522
|
+
if (result.fellBack) flags.push("polar-fallback");
|
|
523
|
+
} else if (!input.timeKnown) {
|
|
524
|
+
flags.push("no-time");
|
|
525
|
+
}
|
|
526
|
+
if (outsideReferenceSpan(input.utc)) flags.push("outside-reference-span");
|
|
527
|
+
return {
|
|
528
|
+
input,
|
|
529
|
+
bodies,
|
|
530
|
+
angles,
|
|
531
|
+
houses,
|
|
532
|
+
aspects: findAspects(bodies),
|
|
533
|
+
flags,
|
|
534
|
+
deltaT: deltaTFor(input.utc, pin),
|
|
535
|
+
engineVersion: ENGINE_VERSION
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
function meanLunarPoints(date) {
|
|
539
|
+
const time = timeOf(date);
|
|
540
|
+
const centuries = time.tt / 36525;
|
|
541
|
+
const nutation = e_tilt(time).dpsi / 3600;
|
|
542
|
+
return { node: meanNodeLongitude(centuries, nutation), apogee: meanApogee(centuries, nutation) };
|
|
543
|
+
}
|
|
544
|
+
function centralSpeed(longitudeOf, date) {
|
|
545
|
+
const before = longitudeOf(sampleDate(date, -SPEED_STEP_DAYS));
|
|
546
|
+
const after = longitudeOf(sampleDate(date, SPEED_STEP_DAYS));
|
|
547
|
+
let difference = after - before;
|
|
548
|
+
if (difference > 180) difference -= 360;
|
|
549
|
+
if (difference < -180) difference += 360;
|
|
550
|
+
return difference / (2 * SPEED_STEP_DAYS);
|
|
551
|
+
}
|
|
552
|
+
function pointPosition(point, lon, lat, speed) {
|
|
553
|
+
const longitude = normalizeLongitude(lon);
|
|
554
|
+
return {
|
|
555
|
+
point,
|
|
556
|
+
lon: longitude,
|
|
557
|
+
lat,
|
|
558
|
+
speed,
|
|
559
|
+
sign: signForLongitude(longitude).slug,
|
|
560
|
+
degree: degreeInSign(longitude)
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
function computePoints(chart) {
|
|
564
|
+
const pin = chart.input.deltaT;
|
|
565
|
+
return evaluated(() => {
|
|
566
|
+
clock(pin);
|
|
567
|
+
try {
|
|
568
|
+
return pointsAt(chart);
|
|
569
|
+
} finally {
|
|
570
|
+
if (pin !== void 0) clock();
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
function computeChartDeclinations(chart) {
|
|
575
|
+
const input = chart?.input;
|
|
576
|
+
const sourceDate = input?.utc;
|
|
577
|
+
const pin = input?.deltaT;
|
|
578
|
+
const bodies = chart?.bodies;
|
|
579
|
+
if (!(sourceDate instanceof Date) || !Number.isFinite(Date.prototype.getTime.call(sourceDate))) {
|
|
580
|
+
throw new RangeError("declination chart must contain a valid input utc Date.");
|
|
581
|
+
}
|
|
582
|
+
const date = new Date(Date.prototype.getTime.call(sourceDate));
|
|
583
|
+
if (pin !== void 0 && (!Number.isFinite(pin) || typeof pin !== "number" || Math.abs(pin) > 1e10)) {
|
|
584
|
+
throw new RangeError("declination chart deltaT must be finite and at most 1e10 seconds in size.");
|
|
585
|
+
}
|
|
586
|
+
return evaluated(() => {
|
|
587
|
+
clock(pin);
|
|
588
|
+
try {
|
|
589
|
+
return {
|
|
590
|
+
...chartBodyDeclinations(bodies, e_tilt(timeOf(date)).tobl),
|
|
591
|
+
utc: date.toISOString(),
|
|
592
|
+
deltaT: deltaTFor(date, pin)
|
|
593
|
+
};
|
|
594
|
+
} finally {
|
|
595
|
+
if (pin !== void 0) clock();
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
function pointsAt(chart) {
|
|
600
|
+
const { utc, latitude, longitude } = chart.input;
|
|
601
|
+
const mean = meanLunarPoints(utc);
|
|
602
|
+
const nodeSpeed = centralSpeed((date) => meanLunarPoints(date).node, utc);
|
|
603
|
+
const apogeeSpeed = centralSpeed((date) => meanLunarPoints(date).apogee.lon, utc);
|
|
604
|
+
const points = [
|
|
605
|
+
pointPosition("Mean Node", mean.node, 0, nodeSpeed),
|
|
606
|
+
pointPosition("Mean South Node", mean.node + 180, 0, nodeSpeed),
|
|
607
|
+
pointPosition("Black Moon Lilith", mean.apogee.lon, mean.apogee.lat, apogeeSpeed)
|
|
608
|
+
];
|
|
609
|
+
if (chart.angles === null || latitude === void 0 || longitude === void 0) {
|
|
610
|
+
return { sect: null, points };
|
|
611
|
+
}
|
|
612
|
+
const time = timeOf(utc);
|
|
613
|
+
const angleInput = {
|
|
614
|
+
gastHours: SiderealTime(time),
|
|
615
|
+
latitude,
|
|
616
|
+
longitude,
|
|
617
|
+
obliquity: e_tilt(time).tobl
|
|
618
|
+
};
|
|
619
|
+
points.push(
|
|
620
|
+
pointPosition("Vertex", vertexOf(angleInput, computeAngles(angleInput)), 0, null),
|
|
621
|
+
pointPosition("East Point", eastPointOf(angleInput), 0, null)
|
|
622
|
+
);
|
|
623
|
+
const lon = (body) => {
|
|
624
|
+
const found = chart.bodies.find((candidate) => candidate.body === body);
|
|
625
|
+
if (!found) throw new RangeError(`chart has no ${body}.`);
|
|
626
|
+
return found.lon;
|
|
627
|
+
};
|
|
628
|
+
const sect = sectOf(chart.angles.asc, lon("Sun"));
|
|
629
|
+
const lots = hellenisticLots(
|
|
630
|
+
{
|
|
631
|
+
ascendant: chart.angles.asc,
|
|
632
|
+
sun: lon("Sun"),
|
|
633
|
+
moon: lon("Moon"),
|
|
634
|
+
mercury: lon("Mercury"),
|
|
635
|
+
venus: lon("Venus"),
|
|
636
|
+
mars: lon("Mars"),
|
|
637
|
+
jupiter: lon("Jupiter"),
|
|
638
|
+
saturn: lon("Saturn")
|
|
639
|
+
},
|
|
640
|
+
sect
|
|
641
|
+
);
|
|
642
|
+
for (const lot of lots) points.push(pointPosition(lot.point, lot.lon, 0, null));
|
|
643
|
+
return { sect, points };
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
export {
|
|
647
|
+
checkedBodyLabel,
|
|
648
|
+
exactSum,
|
|
649
|
+
signOf,
|
|
650
|
+
compareExact,
|
|
651
|
+
absolute,
|
|
652
|
+
roundedValue,
|
|
653
|
+
exactSign,
|
|
654
|
+
DECLINATION_ORB,
|
|
655
|
+
DECLINATION_ORB_LUMINARY,
|
|
656
|
+
DEFAULT_DECLINATION_ORB_POLICY,
|
|
657
|
+
RA_POLE_TOLERANCE,
|
|
658
|
+
SUN_BOUND_LATITUDE,
|
|
659
|
+
eclipticToEquatorial,
|
|
660
|
+
declinationOf,
|
|
661
|
+
declinationOrb,
|
|
662
|
+
findDeclinationAspects,
|
|
663
|
+
declinationsForBodies,
|
|
664
|
+
lunarMeanArguments,
|
|
665
|
+
MEAN_LUNAR_INCLINATION,
|
|
666
|
+
meanNodeLongitude,
|
|
667
|
+
meanApogee,
|
|
668
|
+
sectOf,
|
|
669
|
+
LOTS,
|
|
670
|
+
hellenisticLots,
|
|
671
|
+
antiscion,
|
|
672
|
+
contraAntiscion,
|
|
673
|
+
midpoint,
|
|
674
|
+
bodyLongitude,
|
|
675
|
+
SPEED_STEP_DAYS,
|
|
676
|
+
longitudeSpeed,
|
|
677
|
+
computeBodies,
|
|
678
|
+
computeChart,
|
|
679
|
+
computePoints,
|
|
680
|
+
computeChartDeclinations
|
|
681
|
+
};
|