@zodiacs/engine 0.1.1-rc.15 → 1.0.0

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +891 -0
  2. package/LICENSING.md +192 -12
  3. package/NOTICE +96 -2
  4. package/README.md +296 -66
  5. package/dist/{api-CoB_kqE3.d.ts → api-WbxJ4Wj-.d.ts} +15 -10
  6. package/dist/ayanamsa--YQ46fET.d.ts +134 -0
  7. package/dist/calc.d.ts +390 -0
  8. package/dist/calc.js +1039 -0
  9. package/dist/chunk-47ERTK5X.js +27 -0
  10. package/dist/chunk-7TRLIFFI.js +56 -0
  11. package/dist/chunk-A3U2ZS2W.js +29 -0
  12. package/dist/{chunk-KHBLFXFG.js → chunk-B5LKF437.js} +29 -28
  13. package/dist/{chunk-ONBZ4HK7.js → chunk-BHJXUY67.js} +4 -2
  14. package/dist/{chunk-OYGRVGXD.js → chunk-CHSYDKBL.js} +3 -3
  15. package/dist/{chunk-ZHVI3KWJ.js → chunk-DMGHYCDI.js} +4 -4
  16. package/dist/{chunk-CWI4YUDL.js → chunk-FTX3JDJA.js} +21 -18
  17. package/dist/{chunk-MFF3VKO3.js → chunk-OG4OYTJJ.js} +47 -42
  18. package/dist/{chunk-ZZPITHQS.js → chunk-SRXBTP5H.js} +199 -65
  19. package/dist/{chunk-AECKV73C.js → chunk-TSS2SZWQ.js} +8 -2
  20. package/dist/chunk-WS3TDSP3.js +474 -0
  21. package/dist/chunk-YIITY7Q7.js +483 -0
  22. package/dist/crossings.d.ts +8 -7
  23. package/dist/crossings.js +1 -1
  24. package/dist/deltat.d.ts +28 -3
  25. package/dist/deltat.js +1 -1
  26. package/dist/geo.d.ts +33 -12
  27. package/dist/geo.js +17 -458
  28. package/dist/{internal-math-BbktkHCc.d.ts → houses-CFERsAlK.d.ts} +14 -160
  29. package/dist/houses-extra.d.ts +95 -0
  30. package/dist/houses-extra.js +339 -0
  31. package/dist/index.d.ts +34 -48
  32. package/dist/index.js +31 -23
  33. package/dist/internal-math-DJJ8BYex.d.ts +174 -0
  34. package/dist/internal-math.d.ts +3 -2
  35. package/dist/internal-math.js +2 -2
  36. package/dist/internal.d.ts +1 -1
  37. package/dist/internal.js +5 -5
  38. package/dist/receipt.d.ts +2 -243
  39. package/dist/receipt.js +78 -37
  40. package/dist/reference-span-CILpclrz.d.ts +40 -0
  41. package/dist/rulers-Dla6h_Sm.d.ts +15 -0
  42. package/dist/sky.d.ts +173 -0
  43. package/dist/sky.js +379 -0
  44. package/dist/techniques.d.ts +453 -0
  45. package/dist/techniques.js +823 -0
  46. package/dist/timing.d.ts +113 -17
  47. package/dist/timing.js +98 -64
  48. package/dist/{types-BsWaqwU_.d.ts → types-B-yb_tGL.d.ts} +23 -11
  49. package/dist/vedic.d.ts +42 -124
  50. package/dist/vedic.js +44 -458
  51. package/dist/window.d.ts +180 -0
  52. package/dist/window.js +960 -0
  53. package/dist/zone-history-ghdyO0Sc.d.ts +268 -0
  54. package/package.json +25 -3
@@ -1,67 +1,4 @@
1
- import { k as AspectType, a as BodyPosition, j as Aspect, A as Angles, H as HouseSystem, o as Houses, n as HouseNumber, Z as ZodiacSign, t as SignDefinition } from './types-BsWaqwU_.js';
2
-
3
- interface AspectDefinition {
4
- type: AspectType;
5
- angle: number;
6
- orb: number;
7
- luminaryOrb: number;
8
- }
9
- declare const ASPECT_TYPES: readonly ["conjunction", "sextile", "square", "trine", "opposition"];
10
- declare const ASPECTS: readonly [{
11
- readonly type: "conjunction";
12
- readonly angle: 0;
13
- readonly orb: 8;
14
- readonly luminaryOrb: 10;
15
- }, {
16
- readonly type: "sextile";
17
- readonly angle: 60;
18
- readonly orb: 4;
19
- readonly luminaryOrb: 5;
20
- }, {
21
- readonly type: "square";
22
- readonly angle: 90;
23
- readonly orb: 7;
24
- readonly luminaryOrb: 8;
25
- }, {
26
- readonly type: "trine";
27
- readonly angle: 120;
28
- readonly orb: 7;
29
- readonly luminaryOrb: 8;
30
- }, {
31
- readonly type: "opposition";
32
- readonly angle: 180;
33
- readonly orb: 8;
34
- readonly luminaryOrb: 10;
35
- }];
36
- declare const ASPECT_BODIES: Set<string>;
37
- /** Whether an aspect's orb is shrinking, growing, or neither, at an instant. */
38
- type AspectMotion = "applying" | "separating" | "stationary";
39
- /**
40
- * Below this relative speed, in degrees per day, two bodies are treated as
41
- * not moving against each other, and the aspect as neither applying nor
42
- * separating.
43
- */
44
- declare const STATIONARY_RELATIVE_SPEED = 1e-9;
45
- /**
46
- * The motion of an aspect at the chart instant, from the two longitudes and
47
- * their speeds (degrees per day). It is applying when the orb is strictly
48
- * decreasing: the sign of the orb's rate of change, not a step forward in
49
- * time, decides. An exact aspect (orb 0) can only separate.
50
- */
51
- declare function aspectMotion(a: {
52
- lon: number;
53
- speed: number;
54
- }, b: {
55
- lon: number;
56
- speed: number;
57
- }, angle: number): AspectMotion;
58
- /** Unsigned angular separation in [0, 180]. */
59
- declare function separation(a: number, b: number): number;
60
- declare function matchAspect(aBody: string, aLongitude: number, bBody: string, bLongitude: number): {
61
- definition: AspectDefinition;
62
- orb: number;
63
- } | null;
64
- declare function findAspects(bodies: readonly BodyPosition[]): Aspect[];
1
+ import { A as Angles, H as HouseSystem, a as Houses, b as HouseNumber } from './types-B-yb_tGL.js';
65
2
 
66
3
  declare const HOUSE_SYSTEMS: readonly ["whole", "placidus", "porphyry", "equal", "equal-mc", "vehlow", "koch", "regiomontanus", "campanus", "topocentric", "alcabitius", "morinus", "meridian"];
67
4
  /**
@@ -76,18 +13,28 @@ declare const POLAR_UNDEFINED_HOUSE_SYSTEMS: readonly ["placidus", "koch"];
76
13
  * Porphyry there instead; ask for `"porphyry"` to get that system at any latitude.
77
14
  */
78
15
  declare const POLAR_FALLBACK: "whole";
79
- /** The system Placidus falls back to; the same as {@link POLAR_FALLBACK}. */
16
+ /**
17
+ * The system Placidus falls back to; the same as {@link POLAR_FALLBACK}.
18
+ * @deprecated Koch falls back too; use POLAR_FALLBACK.
19
+ */
80
20
  declare const PLACIDUS_POLAR_FALLBACK: "whole";
81
21
  /** Whether `system` is one that falls back inside the polar circle. */
82
22
  declare function isPolarUndefinedHouseSystem(system: HouseSystem): boolean;
83
23
  /** Mean obliquity of the ecliptic (IAU 2006), in degrees. */
84
24
  declare function meanObliquity(julianCenturies: number): number;
25
+ /**
26
+ * The inputs of the angles and cusps, as natalChart() computes them: the
27
+ * Greenwich apparent sidereal time and the true obliquity of date. A mean
28
+ * sidereal time or the mean obliquity gives other angles (docs/houses.md).
29
+ */
85
30
  interface AngleInput {
86
31
  /** Greenwich apparent sidereal time, in hours. */
87
32
  gastHours: number;
33
+ /** Geodetic latitude, degrees north. */
88
34
  latitude: number;
89
35
  /** East-positive longitude, in degrees. */
90
36
  longitude: number;
37
+ /** The true obliquity of the ecliptic of date, degrees. */
91
38
  obliquity: number;
92
39
  }
93
40
  declare function ramcOf(input: Pick<AngleInput, "gastHours" | "longitude">): number;
@@ -102,7 +49,7 @@ declare function wholeSignCusps(ascendant: number): number[];
102
49
  * the ascensional difference asin(tan φ tan δ(α)) and m = 1/3 or 2/3. With
103
50
  * tan δ = tan ε sin α, |dAD/dα| <= q = |tan φ| tan ε < 1 outside the polar
104
51
  * circle, so the map is a contraction with slope at most 2q/3. The iteration
105
- * settles to 1e-9° within 64 steps except within about 4e-9° of the polar
52
+ * settles to 1e-9° within 64 steps except within about 1e-8° of the polar
106
53
  * limit, near the sidereal times at which a cusp's right ascension reaches 90°
107
54
  * or 270°: it needs up to 63 steps there, and the rounding of asin near ±1
108
55
  * moves each step by about the tolerance. Where it does not settle, the cusp
@@ -188,97 +135,4 @@ declare function computeHouses(system: HouseSystem, input: AngleInput, angles: A
188
135
  };
189
136
  declare function houseOf(longitude: number, cusps: readonly number[]): HouseNumber;
190
137
 
191
- declare const ELEMENTS: readonly ["fire", "earth", "air", "water"];
192
- declare const MODALITIES: readonly ["cardinal", "fixed", "mutable"];
193
- declare const SIGNS: readonly [{
194
- readonly slug: "aries";
195
- readonly name: "Aries";
196
- readonly element: "fire";
197
- readonly modality: "cardinal";
198
- readonly polarity: "day";
199
- readonly naturalHouse: 1;
200
- }, {
201
- readonly slug: "taurus";
202
- readonly name: "Taurus";
203
- readonly element: "earth";
204
- readonly modality: "fixed";
205
- readonly polarity: "night";
206
- readonly naturalHouse: 2;
207
- }, {
208
- readonly slug: "gemini";
209
- readonly name: "Gemini";
210
- readonly element: "air";
211
- readonly modality: "mutable";
212
- readonly polarity: "day";
213
- readonly naturalHouse: 3;
214
- }, {
215
- readonly slug: "cancer";
216
- readonly name: "Cancer";
217
- readonly element: "water";
218
- readonly modality: "cardinal";
219
- readonly polarity: "night";
220
- readonly naturalHouse: 4;
221
- }, {
222
- readonly slug: "leo";
223
- readonly name: "Leo";
224
- readonly element: "fire";
225
- readonly modality: "fixed";
226
- readonly polarity: "day";
227
- readonly naturalHouse: 5;
228
- }, {
229
- readonly slug: "virgo";
230
- readonly name: "Virgo";
231
- readonly element: "earth";
232
- readonly modality: "mutable";
233
- readonly polarity: "night";
234
- readonly naturalHouse: 6;
235
- }, {
236
- readonly slug: "libra";
237
- readonly name: "Libra";
238
- readonly element: "air";
239
- readonly modality: "cardinal";
240
- readonly polarity: "day";
241
- readonly naturalHouse: 7;
242
- }, {
243
- readonly slug: "scorpio";
244
- readonly name: "Scorpio";
245
- readonly element: "water";
246
- readonly modality: "fixed";
247
- readonly polarity: "night";
248
- readonly naturalHouse: 8;
249
- }, {
250
- readonly slug: "sagittarius";
251
- readonly name: "Sagittarius";
252
- readonly element: "fire";
253
- readonly modality: "mutable";
254
- readonly polarity: "day";
255
- readonly naturalHouse: 9;
256
- }, {
257
- readonly slug: "capricorn";
258
- readonly name: "Capricorn";
259
- readonly element: "earth";
260
- readonly modality: "cardinal";
261
- readonly polarity: "night";
262
- readonly naturalHouse: 10;
263
- }, {
264
- readonly slug: "aquarius";
265
- readonly name: "Aquarius";
266
- readonly element: "air";
267
- readonly modality: "fixed";
268
- readonly polarity: "day";
269
- readonly naturalHouse: 11;
270
- }, {
271
- readonly slug: "pisces";
272
- readonly name: "Pisces";
273
- readonly element: "water";
274
- readonly modality: "mutable";
275
- readonly polarity: "night";
276
- readonly naturalHouse: 12;
277
- }];
278
- declare const SIGN_NAMES: readonly ZodiacSign[];
279
- declare function normalizeLongitude(lon: number): number;
280
- declare function signIndexForLongitude(lon: number): number;
281
- declare function signForLongitude(lon: number): SignDefinition;
282
- declare function degreeInSign(lon: number): number;
283
-
284
- export { ASPECTS as A, normalizeLongitude as B, placidusCusps as C, porphyryCusps as D, ELEMENTS as E, ramcOf as F, regiomontanusCusps as G, HOUSE_SYSTEMS as H, separation as I, signForLongitude as J, signIndexForLongitude as K, topocentricCusps as L, MODALITIES as M, vehlowCusps as N, vertexOf as O, PLACIDUS_POLAR_FALLBACK as P, wholeSignCusps as Q, SIGNS as S, ASPECT_BODIES as a, ASPECT_TYPES as b, type AngleInput as c, type AspectDefinition as d, type AspectMotion as e, POLAR_FALLBACK as f, POLAR_UNDEFINED_HOUSE_SYSTEMS as g, SIGN_NAMES as h, STATIONARY_RELATIVE_SPEED as i, alcabitiusCusps as j, aspectMotion as k, campanusCusps as l, computeAngles as m, computeHouses as n, degreeInSign as o, eastPointOf as p, equalCusps as q, equalMcCusps as r, findAspects as s, houseOf as t, isPolarUndefinedHouseSystem as u, kochCusps as v, matchAspect as w, meanObliquity as x, meridianCusps as y, morinusCusps as z };
138
+ export { type AngleInput as A, HOUSE_SYSTEMS as H, PLACIDUS_POLAR_FALLBACK as P, POLAR_FALLBACK as a, POLAR_UNDEFINED_HOUSE_SYSTEMS as b, alcabitiusCusps as c, campanusCusps as d, computeAngles as e, computeHouses as f, eastPointOf as g, equalCusps as h, equalMcCusps as i, houseOf as j, isPolarUndefinedHouseSystem as k, kochCusps as l, meanObliquity as m, meridianCusps as n, morinusCusps as o, placidusCusps as p, porphyryCusps as q, ramcOf as r, regiomontanusCusps as s, topocentricCusps as t, vertexOf as u, vehlowCusps as v, wholeSignCusps as w };
@@ -0,0 +1,95 @@
1
+ import { A as AngleInput } from './houses-CFERsAlK.js';
2
+ import { H as HouseSystem, A as Angles } from './types-B-yb_tGL.js';
3
+ import './deltat.js';
4
+
5
+ /**
6
+ * `@zodiacs/engine/houses`: the house position of a body with ecliptic
7
+ * latitude, the co-ascendants and the polar ascendant, and the speeds of the
8
+ * cusps and the angles. Every function takes the `AngleInput` that
9
+ * `computeAngles` and `computeHouses` take. The entry imports no ephemeris
10
+ * and no module of the root entry. docs/houses.md gives each definition and
11
+ * its source.
12
+ *
13
+ * @module
14
+ */
15
+
16
+ /**
17
+ * The rate of sidereal time: degrees of RAMC per day of UT1,
18
+ * 360.98564736629 (J. Meeus, Astronomical Algorithms, 2nd ed., eq. 12.4).
19
+ * Speeds are derivatives with respect to the RAMC times this rate.
20
+ */
21
+ declare const SIDEREAL_TIME_RATE = 360.98564736629;
22
+ /**
23
+ * The rate of sidereal time, under its first name.
24
+ *
25
+ * @deprecated Use SIDEREAL_TIME_RATE, the same value: this name could be read as a rate of the sidereal zodiac.
26
+ */
27
+ declare const SIDEREAL_RATE = 360.98564736629;
28
+ /** A body's ecliptic longitude and latitude, degrees; the latitude defaults to 0. */
29
+ interface EclipticPosition {
30
+ lon: number;
31
+ lat?: number;
32
+ }
33
+ /** The four points of Swiss Ephemeris's `ascmc[4]` to `ascmc[7]`, degrees in [0, 360). */
34
+ interface CoAscendants {
35
+ /** The ecliptic point at right ascension RAMC + 90°: the ascendant at latitude 0. */
36
+ equatorialAscendant: number;
37
+ /** Walter Koch's: the ascendant for RAMC + 180° at the latitude, plus 180°. */
38
+ kochCoAscendant: number;
39
+ /** Michael Munkasey's: the ascendant for the RAMC at the colatitude. */
40
+ munkaseyCoAscendant: number;
41
+ /** Michael Munkasey's polar ascendant: the ascendant for RAMC + 180° at the latitude. */
42
+ polarAscendant: number;
43
+ }
44
+ /**
45
+ * Speeds in degrees per day, at the sidereal rate, with latitude and obliquity fixed.
46
+ *
47
+ * @experimental As houseSpeeds is.
48
+ */
49
+ interface HouseSpeeds {
50
+ /** The system of the cusps: the one asked for, or whole sign where Placidus or Koch falls back. */
51
+ system: HouseSystem;
52
+ fellBack: boolean;
53
+ /** In the order of `computeHouses`'s cusps: index 0 is the 1st house. */
54
+ cusps: number[];
55
+ /** The ascendant and descendant share a speed, as do the midheaven and imum coeli. */
56
+ angles: Angles;
57
+ }
58
+ /**
59
+ * The house position of a body in `system`, as Swiss Ephemeris's
60
+ * `swe_house_pos` defines it: a number in [1, 13) whose integer part is the
61
+ * house and whose fraction is how far through the house the body is, so that
62
+ * (position − 1) × 30 is its mundane position in degrees. The body's ecliptic
63
+ * latitude enters through the system's own house circles (docs/houses.md).
64
+ * `null` where the system does not define a position: Koch, where the body
65
+ * lies outside the house circles of its half of the sky or the midheaven
66
+ * never rises; Topocentric, where no circle passes through a body that never
67
+ * rises or sets. Invalid input throws RangeError.
68
+ */
69
+ declare function housePosition(system: HouseSystem, input: AngleInput, body: EclipticPosition): number | null;
70
+ /**
71
+ * The equatorial ascendant, Koch's and Munkasey's co-ascendants and
72
+ * Munkasey's polar ascendant (Swiss Ephemeris's `ascmc[4]` to `ascmc[7]`).
73
+ * Each is the ecliptic point of an oblique ascension under a pole, taken as
74
+ * the formula gives it: inside the polar circle (and, for Munkasey's
75
+ * co-ascendant, within 90° − ε of the equator) it can lie west of the
76
+ * meridian, and it is not turned east as the ascendant is.
77
+ */
78
+ declare function coAscendants(input: AngleInput): CoAscendants;
79
+ /**
80
+ * The speeds of the cusps `computeHouses(system, input, …)` returns and of
81
+ * the four angles, in degrees per day: each derivative with respect to the
82
+ * RAMC, found analytically, times {@link SIDEREAL_TIME_RATE}, with the latitude
83
+ * and the obliquity held fixed. Where Placidus or Koch falls back to whole
84
+ * signs, the cusps are whole-sign cusps, whose speed is 0 except where the
85
+ * ascendant changes sign. A speed is not defined at the instants where a cusp
86
+ * jumps: whole-sign cusps at a change of sign, and every cusp that turns with
87
+ * the ascendant inside the polar circle. Invalid input throws RangeError.
88
+ *
89
+ * @experimental What a speed is here (a derivative with the latitude and the
90
+ * obliquity held fixed, 0 for whole-sign cusps) differs from Swiss
91
+ * Ephemeris's for several systems, and may change in a minor release.
92
+ */
93
+ declare function houseSpeeds(system: HouseSystem, input: AngleInput): HouseSpeeds;
94
+
95
+ export { AngleInput, Angles, type CoAscendants, type EclipticPosition, type HouseSpeeds, HouseSystem, SIDEREAL_RATE, SIDEREAL_TIME_RATE, coAscendants, housePosition, houseSpeeds };
@@ -0,0 +1,339 @@
1
+ // src/houses-extra.ts
2
+ var DEG = Math.PI / 180;
3
+ var RAD = 180 / Math.PI;
4
+ var SIDEREAL_TIME_RATE = 360.98564736629;
5
+ var SIDEREAL_RATE = SIDEREAL_TIME_RATE;
6
+ var SYSTEMS = [
7
+ "whole",
8
+ "placidus",
9
+ "porphyry",
10
+ "equal",
11
+ "equal-mc",
12
+ "vehlow",
13
+ "koch",
14
+ "regiomontanus",
15
+ "campanus",
16
+ "topocentric",
17
+ "alcabitius",
18
+ "morinus",
19
+ "meridian"
20
+ ];
21
+ var normalize = (value) => (value % 360 + 360) % 360;
22
+ var inCircle = (value) => value >= 0 && value < 360 ? value : normalize(value);
23
+ function finiteNumber(value, label) {
24
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new RangeError(`${label} must be a finite number.`);
25
+ return value;
26
+ }
27
+ function placeOf(input) {
28
+ if (input === null || typeof input !== "object") throw new RangeError("input must be an AngleInput object.");
29
+ const gastHours = finiteNumber(input.gastHours, "gastHours");
30
+ const longitude = finiteNumber(input.longitude, "longitude");
31
+ const latitude = finiteNumber(input.latitude, "latitude");
32
+ const obliquity = finiteNumber(input.obliquity, "obliquity");
33
+ if (Math.abs(latitude) > 90) throw new RangeError("latitude must be within [-90, 90] degrees.");
34
+ if (!(obliquity > 0 && obliquity < 90)) throw new RangeError("obliquity must be between 0 and 90 degrees.");
35
+ return { ramc: normalize(gastHours * 15 + longitude), latitude, obliquity };
36
+ }
37
+ function systemOf(system) {
38
+ if (typeof system === "string" && SYSTEMS.includes(system)) return system;
39
+ throw new RangeError(`Unknown house system ${String(system)}.`);
40
+ }
41
+ function anglesOf({ ramc, latitude, obliquity }) {
42
+ const ra = ramc * DEG;
43
+ const eps = obliquity * DEG;
44
+ const mc = normalize(Math.atan2(Math.sin(ra), Math.cos(ra) * Math.cos(eps)) * RAD);
45
+ let asc = normalize(
46
+ Math.atan2(Math.cos(ra), -(Math.sin(ra) * Math.cos(eps) + Math.tan(latitude * DEG) * Math.sin(eps))) * RAD
47
+ );
48
+ if (normalize(asc - mc) >= 180) asc = normalize(asc + 180);
49
+ return { asc, mc };
50
+ }
51
+ function obliqueLongitude(ascension, pole, obliquity) {
52
+ const a = ascension * DEG;
53
+ const e = obliquity * DEG;
54
+ return normalize(Math.atan2(Math.sin(a), Math.cos(a) * Math.cos(e) - Math.tan(pole * DEG) * Math.sin(e)) * RAD);
55
+ }
56
+ function equatorialOf(place, body) {
57
+ if (body === null || typeof body !== "object") throw new RangeError("body must be an object with lon and lat.");
58
+ const lon = finiteNumber(body.lon, "body lon");
59
+ const lat = body.lat === void 0 ? 0 : finiteNumber(body.lat, "body lat");
60
+ if (Math.abs(lat) > 90) throw new RangeError("body lat must be within [-90, 90] degrees.");
61
+ const l = lon * DEG;
62
+ const b = lat * DEG;
63
+ const e = place.obliquity * DEG;
64
+ const x = Math.cos(b) * Math.cos(l);
65
+ const y = Math.cos(b) * Math.sin(l) * Math.cos(e) - Math.sin(b) * Math.sin(e);
66
+ const z = Math.cos(b) * Math.sin(l) * Math.sin(e) + Math.sin(b) * Math.cos(e);
67
+ return { md: normalize(Math.atan2(y, x) * RAD - place.ramc), dec: Math.atan2(z, Math.hypot(x, y)) * RAD };
68
+ }
69
+ function semiArc(a) {
70
+ return a >= 1 ? 180 : a <= -1 ? 0 : 90 + Math.asin(a) * RAD;
71
+ }
72
+ var diurnalSemiArc = (tanLatitude, dec) => semiArc(tanLatitude * Math.tan(dec * DEG));
73
+ function byQuadrants(md, dec, east) {
74
+ if (md < 180) return east(md, dec);
75
+ const opposite = east(md - 180, -dec);
76
+ return opposite === null ? null : opposite + 180;
77
+ }
78
+ function placidusEast(tanLatitude) {
79
+ return (md, dec) => {
80
+ const day = diurnalSemiArc(tanLatitude, dec);
81
+ return md < day ? 270 + 90 * md / day : 90 * (md - day) / (180 - day);
82
+ };
83
+ }
84
+ function kochEast(place, tanLatitude) {
85
+ const day = semiArc(tanLatitude * Math.tan(place.obliquity * DEG) * Math.sin(place.ramc * DEG));
86
+ if (!(day > 0)) return null;
87
+ return (md, dec) => {
88
+ const position = 90 * (md - diurnalSemiArc(tanLatitude, dec)) / day;
89
+ if (!(Math.abs(position) <= 90 + 1e-9)) return null;
90
+ return Math.min(90, Math.max(-90, position));
91
+ };
92
+ }
93
+ function root(f, low, high) {
94
+ const atLow = f(low);
95
+ const atHigh = f(high);
96
+ if (atLow === 0) return low;
97
+ if (atHigh === 0) return high;
98
+ if (!(Math.sign(atLow) === -Math.sign(atHigh))) return null;
99
+ let lower = low;
100
+ let upper = high;
101
+ for (let step = 0; step < 200; step += 1) {
102
+ const middle = (lower + upper) / 2;
103
+ if (!(middle > lower && middle < upper)) break;
104
+ if (Math.sign(f(middle)) === Math.sign(atLow)) lower = middle;
105
+ else upper = middle;
106
+ }
107
+ return (lower + upper) / 2;
108
+ }
109
+ function topocentricEast(tanLatitude) {
110
+ return (md, dec) => {
111
+ const a = tanLatitude * Math.tan(dec * DEG);
112
+ const asin = (x) => Math.asin(Math.min(1, Math.max(-1, x))) * RAD;
113
+ const circumpolar = Math.abs(a) > 1;
114
+ const reach = circumpolar ? 1 / Math.abs(a) : 1;
115
+ const above = md < diurnalSemiArc(tanLatitude, dec);
116
+ const s = above ? root((t) => md - 90 * t - asin(t * a), 0, reach) : root((t) => md - 90 - 90 * t - asin((1 - t) * a), 1 - reach, 1);
117
+ const circle = s ?? (circumpolar ? null : above ? 1 : 0);
118
+ if (circle === null) return null;
119
+ return above ? 270 + 90 * circle : 90 * circle;
120
+ };
121
+ }
122
+ function alcabitiusEast(place, asc, tanLatitude) {
123
+ const declination = Math.asin(Math.sin(place.obliquity * DEG) * Math.sin(asc * DEG)) * RAD;
124
+ const day = Math.acos(Math.min(1, Math.max(-1, -tanLatitude * Math.tan(declination * DEG)))) * RAD;
125
+ return (md) => md < day ? 270 + 90 * md / day : 90 * (md - day) / (180 - day);
126
+ }
127
+ function porphyryPosition(lon, asc, mc) {
128
+ const upper = normalize(asc - mc);
129
+ const lower = normalize(normalize(mc + 180) - asc);
130
+ const fromMc = normalize(lon - mc);
131
+ if (fromMc < upper) return 270 + 90 * fromMc / upper;
132
+ if (fromMc < 180) return 90 * (fromMc - upper) / lower;
133
+ if (fromMc < 180 + upper) return 90 + 90 * (fromMc - 180) / upper;
134
+ return 180 + 90 * (fromMc - 180 - upper) / lower;
135
+ }
136
+ function housePosition(system, input, body) {
137
+ const name = systemOf(system);
138
+ const place = placeOf(input);
139
+ const { asc, mc } = anglesOf(place);
140
+ const { md, dec } = equatorialOf(place, body);
141
+ const lon = inCircle(body.lon);
142
+ const tanLatitude = Math.tan(place.latitude * DEG);
143
+ let mundane;
144
+ switch (name) {
145
+ case "whole":
146
+ mundane = lon - Math.floor(asc / 30) * 30;
147
+ break;
148
+ case "equal":
149
+ mundane = lon - asc;
150
+ break;
151
+ case "vehlow":
152
+ mundane = lon - asc + 15;
153
+ break;
154
+ case "equal-mc":
155
+ mundane = lon - mc - 90;
156
+ break;
157
+ case "porphyry":
158
+ mundane = porphyryPosition(lon, asc, mc);
159
+ break;
160
+ case "morinus": {
161
+ const e = place.obliquity * DEG;
162
+ mundane = Math.atan2(Math.sin(lon * DEG), Math.cos(lon * DEG) * Math.cos(e)) * RAD - place.ramc - 90;
163
+ break;
164
+ }
165
+ case "meridian":
166
+ mundane = md - 90;
167
+ break;
168
+ case "campanus":
169
+ case "regiomontanus": {
170
+ const phi = place.latitude * DEG;
171
+ const east = Math.cos(dec * DEG) * Math.sin(md * DEG);
172
+ const zenith = Math.cos(phi) * Math.cos(dec * DEG) * Math.cos(md * DEG) + Math.sin(phi) * Math.sin(dec * DEG);
173
+ mundane = Math.atan2(name === "campanus" ? east : east * Math.cos(phi), zenith) * RAD - 90;
174
+ break;
175
+ }
176
+ case "placidus":
177
+ mundane = byQuadrants(md, dec, placidusEast(tanLatitude));
178
+ break;
179
+ case "koch": {
180
+ const east = kochEast(place, tanLatitude);
181
+ mundane = east === null ? null : byQuadrants(md, dec, east);
182
+ break;
183
+ }
184
+ case "topocentric":
185
+ mundane = byQuadrants(md, dec, topocentricEast(tanLatitude));
186
+ break;
187
+ case "alcabitius":
188
+ mundane = byQuadrants(md, dec, alcabitiusEast(place, asc, tanLatitude));
189
+ break;
190
+ default:
191
+ throw new RangeError(`Unknown house system ${String(name)}.`);
192
+ }
193
+ return mundane === null ? null : inCircle(mundane) / 30 + 1;
194
+ }
195
+ function coAscendants(input) {
196
+ const { ramc, latitude, obliquity } = placeOf(input);
197
+ const polar = obliqueLongitude(ramc + 270, latitude, obliquity);
198
+ return {
199
+ equatorialAscendant: obliqueLongitude(ramc + 90, 0, obliquity),
200
+ kochCoAscendant: normalize(polar + 180),
201
+ munkaseyCoAscendant: obliqueLongitude(ramc + 90, latitude >= 0 ? 90 - latitude : -90 - latitude, obliquity),
202
+ polarAscendant: polar
203
+ };
204
+ }
205
+ function obliqueRate(ascension, tanPole, obliquity) {
206
+ const a = ascension * DEG;
207
+ const e = obliquity * DEG;
208
+ const k = tanPole * Math.sin(e);
209
+ const across = Math.cos(a) * Math.cos(e) - k;
210
+ return (Math.cos(e) - k * Math.cos(a)) / (Math.sin(a) ** 2 + across * across);
211
+ }
212
+ function ascensionalRate(q, x) {
213
+ const sine = Math.sin(x * DEG);
214
+ return q * Math.cos(x * DEG) / Math.sqrt(1 - q * q * sine * sine);
215
+ }
216
+ function quadrantRates(asc, mc, c11, c12, c2, c3) {
217
+ return [asc, c2, c3, mc, c11, c12, asc, c2, c3, mc, c11, c12];
218
+ }
219
+ function placidusAscension(ramc, offset, m, q) {
220
+ const low = ramc + offset - 90 * m - 1;
221
+ const high = ramc + offset + 90 * m + 1;
222
+ const found = root(
223
+ (alpha) => alpha - ramc - offset - m * Math.asin(Math.min(1, Math.max(-1, q * Math.sin(alpha * DEG)))) * RAD,
224
+ low,
225
+ high
226
+ );
227
+ return found ?? (low + high) / 2;
228
+ }
229
+ function cuspRates(system, place, asc, ascRate, mcRate) {
230
+ const { ramc, latitude, obliquity } = place;
231
+ const tanLatitude = Math.tan(latitude * DEG);
232
+ const q = tanLatitude * Math.tan(obliquity * DEG);
233
+ const circles = (ascensions, tanPoles) => {
234
+ const [c11, c12, c2, c3] = ascensions.map((offset, index) => obliqueRate(ramc + offset, tanPoles[index], obliquity));
235
+ return quadrantRates(ascRate, mcRate, c11, c12, c2, c3);
236
+ };
237
+ switch (system) {
238
+ case "whole":
239
+ return Array.from({ length: 12 }, () => 0);
240
+ case "equal":
241
+ case "vehlow":
242
+ return Array.from({ length: 12 }, () => ascRate);
243
+ case "equal-mc":
244
+ return Array.from({ length: 12 }, () => mcRate);
245
+ case "porphyry": {
246
+ const third = (ascRate - mcRate) / 3;
247
+ return quadrantRates(ascRate, mcRate, mcRate + third, mcRate + 2 * third, ascRate - third, ascRate - 2 * third);
248
+ }
249
+ case "meridian":
250
+ return Array.from({ length: 12 }, (_, index) => obliqueRate(ramc + 90 + index * 30, 0, obliquity));
251
+ case "morinus": {
252
+ const cosine = Math.cos(obliquity * DEG);
253
+ return Array.from({ length: 12 }, (_, index) => {
254
+ const a = (ramc + 90 + index * 30) * DEG;
255
+ return cosine / (Math.cos(a) ** 2 + Math.sin(a) ** 2 * cosine * cosine);
256
+ });
257
+ }
258
+ case "regiomontanus": {
259
+ const near = tanLatitude * 0.5;
260
+ const far = tanLatitude * Math.cos(30 * DEG);
261
+ return circles([30, 60, 120, 150], [near, far, far, near]);
262
+ }
263
+ case "topocentric": {
264
+ const near = tanLatitude / 3;
265
+ const far = tanLatitude * 2 / 3;
266
+ return circles([30, 60, 120, 150], [near, far, far, near]);
267
+ }
268
+ case "campanus": {
269
+ const sine = Math.sin(latitude * DEG);
270
+ const cosine = Math.cos(latitude * DEG);
271
+ const near = Math.tan(Math.asin(sine / 2));
272
+ const far = Math.tan(Math.asin(Math.sqrt(3) / 2 * sine));
273
+ const wide = Math.atan(Math.sqrt(3) / cosine) * RAD;
274
+ const narrow = Math.atan(1 / (Math.sqrt(3) * cosine)) * RAD;
275
+ return circles([90 - wide, 90 - narrow, 90 + narrow, 90 + wide], [near, far, far, near]);
276
+ }
277
+ case "alcabitius": {
278
+ const e = obliquity * DEG;
279
+ const declination = Math.asin(Math.sin(e) * Math.sin(asc * DEG));
280
+ const u = -tanLatitude * Math.tan(declination);
281
+ const day = Math.acos(Math.min(1, Math.max(-1, u))) * RAD;
282
+ const tanRate = Math.sin(e) * Math.cos(asc * DEG) * ascRate / Math.cos(declination) ** 3;
283
+ const dayRate = Math.abs(u) < 1 ? tanLatitude * tanRate / Math.sqrt(1 - u * u) : 0;
284
+ const at = (ascension, share) => obliqueRate(ramc + ascension, 0, obliquity) * (1 + share * dayRate);
285
+ return quadrantRates(
286
+ ascRate,
287
+ mcRate,
288
+ at(day / 3, 1 / 3),
289
+ at(2 * day / 3, 2 / 3),
290
+ at(60 + 2 * day / 3, 2 / 3),
291
+ at(120 + day / 3, 1 / 3)
292
+ );
293
+ }
294
+ case "koch": {
295
+ if (Math.abs(latitude) >= 90 - obliquity) return null;
296
+ const third = (90 + Math.asin(q * Math.sin(ramc * DEG)) * RAD) / 3;
297
+ const thirdRate = ascensionalRate(q, ramc) / 3;
298
+ const at = (thirds) => obliqueRate(ramc + 90 + thirds * third, tanLatitude, obliquity) * (1 + thirds * thirdRate);
299
+ return quadrantRates(ascRate, mcRate, at(-2), at(-1), at(1), at(2));
300
+ }
301
+ case "placidus": {
302
+ if (Math.abs(latitude) >= 90 - obliquity) return null;
303
+ const cosine = Math.cos(obliquity * DEG);
304
+ const at = (offset, m) => {
305
+ const alpha = placidusAscension(ramc, offset, m, q);
306
+ const a = alpha * DEG;
307
+ const longitudeRate = cosine / (Math.sin(a) ** 2 + Math.cos(a) ** 2 * cosine * cosine);
308
+ return longitudeRate / (1 - m * ascensionalRate(q, alpha));
309
+ };
310
+ return quadrantRates(ascRate, mcRate, at(30, 1 / 3), at(60, 2 / 3), at(120, 2 / 3), at(150, 1 / 3));
311
+ }
312
+ default:
313
+ throw new RangeError(`Unknown house system ${String(system)}.`);
314
+ }
315
+ }
316
+ function houseSpeeds(system, input) {
317
+ const name = systemOf(system);
318
+ const place = placeOf(input);
319
+ const { asc } = anglesOf(place);
320
+ const ascRate = obliqueRate(place.ramc + 90, Math.tan(place.latitude * DEG), place.obliquity);
321
+ const mcRate = obliqueRate(place.ramc, 0, place.obliquity);
322
+ const rates = cuspRates(name, place, asc, ascRate, mcRate);
323
+ const perDay = (rate) => rate * SIDEREAL_TIME_RATE;
324
+ const ascSpeed = perDay(ascRate);
325
+ const mcSpeed = perDay(mcRate);
326
+ return {
327
+ system: rates === null ? "whole" : name,
328
+ fellBack: rates === null,
329
+ cusps: rates === null ? Array.from({ length: 12 }, () => 0) : rates.map(perDay),
330
+ angles: { asc: ascSpeed, mc: mcSpeed, dsc: ascSpeed, ic: mcSpeed }
331
+ };
332
+ }
333
+ export {
334
+ SIDEREAL_RATE,
335
+ SIDEREAL_TIME_RATE,
336
+ coAscendants,
337
+ housePosition,
338
+ houseSpeeds
339
+ };