kaabalah 5.4.0 → 5.5.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.
@@ -76,6 +76,17 @@ var CalcFlag = /* @__PURE__ */ ((CalcFlag2) => {
76
76
  CalcFlag2[CalcFlag2["SIDEREAL"] = 65536] = "SIDEREAL";
77
77
  return CalcFlag2;
78
78
  })(CalcFlag || {});
79
+ var RiseTransitFlag = /* @__PURE__ */ ((RiseTransitFlag2) => {
80
+ RiseTransitFlag2[RiseTransitFlag2["RISE"] = 1] = "RISE";
81
+ RiseTransitFlag2[RiseTransitFlag2["SET"] = 2] = "SET";
82
+ RiseTransitFlag2[RiseTransitFlag2["UPPER_MERIDIAN"] = 4] = "UPPER_MERIDIAN";
83
+ RiseTransitFlag2[RiseTransitFlag2["LOWER_MERIDIAN"] = 8] = "LOWER_MERIDIAN";
84
+ RiseTransitFlag2[RiseTransitFlag2["DISC_CENTER"] = 256] = "DISC_CENTER";
85
+ RiseTransitFlag2[RiseTransitFlag2["NO_REFRACTION"] = 512] = "NO_REFRACTION";
86
+ return RiseTransitFlag2;
87
+ })(RiseTransitFlag || {});
88
+ var SE_ECL2HOR = 0;
89
+ var SE_EQU2HOR = 1;
79
90
  var SE_AST_OFFSET = 1e4;
80
91
  var BODY = {
81
92
  MEAN_APOGEE: 12,
@@ -95,6 +106,8 @@ var SwissEph = class {
95
106
  this.swe_close = null;
96
107
  this.swe_set_topo = null;
97
108
  this.swe_set_sid_mode = null;
109
+ this.swe_azalt_fn = null;
110
+ this.swe_rise_trans_fn = null;
98
111
  this.module = module;
99
112
  this.swe_julday = this.module.cwrap("swe_julday", "number", [
100
113
  "number",
@@ -139,6 +152,16 @@ var SwissEph = class {
139
152
  null,
140
153
  ["number", "number", "number"]
141
154
  );
155
+ this.swe_azalt_fn = this.module.cwrap(
156
+ "swe_azalt",
157
+ null,
158
+ ["number", "number", "number", "number", "number", "number", "number"]
159
+ );
160
+ this.swe_rise_trans_fn = this.module.cwrap(
161
+ "swe_rise_trans",
162
+ "number",
163
+ ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]
164
+ );
142
165
  }
143
166
  checkInitialized() {
144
167
  if (!this.module) {
@@ -345,6 +368,105 @@ var SwissEph = class {
345
368
  const id = kind === "mean" ? BODY.MEAN_APOGEE : BODY.OSC_APOGEE;
346
369
  return this.calculatePlanetPosition(julday, id, flags);
347
370
  }
371
+ /**
372
+ * Convert ecliptic (or equatorial) coordinates to horizon coordinates.
373
+ * Returns azimuth (0=south, 90=west, 180=north, 270=east) and altitude.
374
+ */
375
+ azalt(julday, longitude, latitude, altitude, xinLon, xinLat, xinDist, fromEquatorial = false) {
376
+ this.checkInitialized();
377
+ if (!this.swe_azalt_fn) {
378
+ throw new Error("swe_azalt function not available");
379
+ }
380
+ const BYTES = 8;
381
+ const geoPtr = this.module._malloc(3 * BYTES);
382
+ const xinPtr = this.module._malloc(3 * BYTES);
383
+ const xazPtr = this.module._malloc(3 * BYTES);
384
+ if (!geoPtr || !xinPtr || !xazPtr) {
385
+ if (geoPtr) this.module._free(geoPtr);
386
+ if (xinPtr) this.module._free(xinPtr);
387
+ if (xazPtr) this.module._free(xazPtr);
388
+ throw new Error("Memory allocation failed for azalt");
389
+ }
390
+ try {
391
+ this.module.setValue(geoPtr, longitude, "double");
392
+ this.module.setValue(geoPtr + BYTES, latitude, "double");
393
+ this.module.setValue(geoPtr + 2 * BYTES, altitude, "double");
394
+ this.module.setValue(xinPtr, xinLon, "double");
395
+ this.module.setValue(xinPtr + BYTES, xinLat, "double");
396
+ this.module.setValue(xinPtr + 2 * BYTES, xinDist, "double");
397
+ this.swe_azalt_fn(
398
+ julday,
399
+ fromEquatorial ? SE_EQU2HOR : SE_ECL2HOR,
400
+ geoPtr,
401
+ 0,
402
+ // atpress (0 = default 1013.25 mbar)
403
+ 0,
404
+ // attemp (0 = default 15°C)
405
+ xinPtr,
406
+ xazPtr
407
+ );
408
+ return {
409
+ azimuth: this.module.getValue(xazPtr, "double"),
410
+ trueAltitude: this.module.getValue(xazPtr + BYTES, "double"),
411
+ apparentAltitude: this.module.getValue(xazPtr + 2 * BYTES, "double")
412
+ };
413
+ } finally {
414
+ this.module._free(geoPtr);
415
+ this.module._free(xinPtr);
416
+ this.module._free(xazPtr);
417
+ }
418
+ }
419
+ /**
420
+ * Find the next rise, set, or meridian transit of a planet.
421
+ * Returns the Julian day of the event.
422
+ */
423
+ riseTransit(julday, planet, rsmi, longitude, latitude, altitude = 0, flags = 2 /* SWISS_EPH */) {
424
+ this.checkInitialized();
425
+ if (!this.swe_rise_trans_fn) {
426
+ throw new Error("swe_rise_trans function not available");
427
+ }
428
+ const BYTES = 8;
429
+ const geoPtr = this.module._malloc(3 * BYTES);
430
+ const tretPtr = this.module._malloc(BYTES);
431
+ const ERR_BYTES = 512;
432
+ const errPtr = this.module._malloc(ERR_BYTES);
433
+ if (!geoPtr || !tretPtr || !errPtr) {
434
+ if (geoPtr) this.module._free(geoPtr);
435
+ if (tretPtr) this.module._free(tretPtr);
436
+ if (errPtr) this.module._free(errPtr);
437
+ throw new Error("Memory allocation failed for riseTransit");
438
+ }
439
+ this.module.HEAP8.fill(0, errPtr, errPtr + ERR_BYTES);
440
+ try {
441
+ this.module.setValue(geoPtr, longitude, "double");
442
+ this.module.setValue(geoPtr + BYTES, latitude, "double");
443
+ this.module.setValue(geoPtr + 2 * BYTES, altitude, "double");
444
+ const ret = this.swe_rise_trans_fn(
445
+ julday,
446
+ planet,
447
+ 0,
448
+ // starname pointer (0 = planet, not fixed star)
449
+ flags,
450
+ rsmi,
451
+ geoPtr,
452
+ 0,
453
+ // atpress
454
+ 0,
455
+ // attemp
456
+ tretPtr,
457
+ errPtr
458
+ );
459
+ if (ret < 0) {
460
+ const msg = this.module.UTF8ToString(errPtr);
461
+ throw new Error(msg || `swe_rise_trans failed with code ${ret}`);
462
+ }
463
+ return this.module.getValue(tretPtr, "double");
464
+ } finally {
465
+ this.module._free(geoPtr);
466
+ this.module._free(tretPtr);
467
+ this.module._free(errPtr);
468
+ }
469
+ }
348
470
  };
349
471
  function parsFortunae(asc, sunLon, moonLon, diurnal) {
350
472
  const val = diurnal ? asc + moonLon - sunLon : asc + sunLon - moonLon;
@@ -590,6 +712,24 @@ function calculateSinglePlanetPosition(date, planet) {
590
712
  const julday = swissEph.getJulianDay(date);
591
713
  return swissEph.calculatePlanetPosition(julday, planet, DEFAULT_FLAGS);
592
714
  }
715
+ function calculateEquatorialPosition(date, planet) {
716
+ checkInitialization();
717
+ const julday = swissEph.getJulianDay(date);
718
+ const pos = swissEph.calculatePlanetPosition(
719
+ julday,
720
+ planet,
721
+ 2 /* SWISS_EPH */ | 2048 /* EQUATORIAL */
722
+ );
723
+ return {
724
+ rightAscension: pos.longitude,
725
+ declination: pos.latitude,
726
+ distance: pos.distance
727
+ };
728
+ }
729
+ function getJulianDay(date) {
730
+ checkInitialization();
731
+ return swissEph.getJulianDay(date);
732
+ }
593
733
  async function calculatePlanetaryPositions(date) {
594
734
  try {
595
735
  checkInitialization();
@@ -756,6 +896,181 @@ async function toUtcDate(local, latitude, longitude, options = {}) {
756
896
  return localToUtcDate(local, latitude, longitude, options);
757
897
  }
758
898
 
899
+ // src/astrology/astrocartography.ts
900
+ var ASTROCARTOGRAPHY_DEFAULT_PLANETS = [
901
+ 0 /* SUN */,
902
+ 1 /* MOON */,
903
+ 2 /* MERCURY */,
904
+ 3 /* VENUS */,
905
+ 4 /* MARS */,
906
+ 5 /* JUPITER */,
907
+ 6 /* SATURN */,
908
+ 7 /* URANUS */,
909
+ 8 /* NEPTUNE */,
910
+ 9 /* PLUTO */,
911
+ 15 /* CHIRON */,
912
+ 11 /* TRUE_NODE */
913
+ ];
914
+ var DEG = Math.PI / 180;
915
+ function computeGMST(julianDay) {
916
+ return normalizeAngle(
917
+ 280.46061837 + 360.98564736629 * (julianDay - 2451545)
918
+ );
919
+ }
920
+ function computeMCLongitude(gmst, ra) {
921
+ return toGeoLon(normalizeAngle(gmst - ra));
922
+ }
923
+ function computeICLongitude(gmst, ra) {
924
+ return toGeoLon(normalizeAngle(gmst - ra + 180));
925
+ }
926
+ function computeHorizonLongitude(gmst, ra, dec, latitude, angle) {
927
+ const tanPhi = Math.tan(latitude * DEG);
928
+ const tanDelta = Math.tan(dec * DEG);
929
+ const cosH = -(tanPhi * tanDelta);
930
+ if (Math.abs(cosH) > 1) return null;
931
+ const H = Math.acos(cosH) / DEG;
932
+ const lon = angle === "AC" ? normalizeAngle(gmst - ra - H) : normalizeAngle(gmst - ra + H);
933
+ return toGeoLon(lon);
934
+ }
935
+ function geographicAngularDifference(a, b) {
936
+ const d = normalizeAngle(a - b);
937
+ return d > 180 ? 360 - d : d;
938
+ }
939
+ function toGeoLon(deg360) {
940
+ const n = normalizeAngle(deg360);
941
+ return n > 180 ? n - 360 : n;
942
+ }
943
+ function computeEquatorialPositions(date, planets = ASTROCARTOGRAPHY_DEFAULT_PLANETS) {
944
+ const result = {};
945
+ for (const p of planets) {
946
+ const name = PLANET_AND_NODE_NAMES[p];
947
+ const eq = calculateEquatorialPosition(date, p);
948
+ result[name] = {
949
+ ra: eq.rightAscension,
950
+ dec: eq.declination,
951
+ planetId: p
952
+ };
953
+ }
954
+ return result;
955
+ }
956
+ function findParansAtLatitude(equatorialPositions, gmst, latitude, paranOrb = 1) {
957
+ const ANGLES = ["MC", "IC", "AC", "DC"];
958
+ const lines = [];
959
+ for (const [name, eq] of Object.entries(equatorialPositions)) {
960
+ for (const angle of ANGLES) {
961
+ let lon;
962
+ if (angle === "MC") lon = computeMCLongitude(gmst, eq.ra);
963
+ else if (angle === "IC") lon = computeICLongitude(gmst, eq.ra);
964
+ else lon = computeHorizonLongitude(gmst, eq.ra, eq.dec, latitude, angle);
965
+ if (lon !== null) {
966
+ lines.push({ planet: name, angle, longitude: lon });
967
+ }
968
+ }
969
+ }
970
+ const parans = [];
971
+ for (let i = 0; i < lines.length; i++) {
972
+ for (let j = i + 1; j < lines.length; j++) {
973
+ const a = lines[i];
974
+ const b = lines[j];
975
+ if (a.planet === b.planet) continue;
976
+ if (a.angle === b.angle) continue;
977
+ const dist = geographicAngularDifference(a.longitude, b.longitude);
978
+ if (dist <= paranOrb) {
979
+ parans.push({
980
+ latitude,
981
+ planetA: a.planet,
982
+ angleA: a.angle,
983
+ longitudeA: a.longitude,
984
+ planetB: b.planet,
985
+ angleB: b.angle,
986
+ longitudeB: b.longitude
987
+ });
988
+ }
989
+ }
990
+ }
991
+ return parans;
992
+ }
993
+ function queryAstrocartographyLocation(date, options) {
994
+ const {
995
+ latitude,
996
+ longitude,
997
+ orb = 2,
998
+ planets = ASTROCARTOGRAPHY_DEFAULT_PLANETS,
999
+ paranOrb = 1
1000
+ } = options;
1001
+ const jd = getJulianDay(date);
1002
+ const gmst = computeGMST(jd);
1003
+ const positions = computeEquatorialPositions(date, planets);
1004
+ const lines = [];
1005
+ const ANGLES = ["MC", "IC", "AC", "DC"];
1006
+ for (const [name, eq] of Object.entries(positions)) {
1007
+ for (const angle of ANGLES) {
1008
+ let lineLon;
1009
+ if (angle === "MC") lineLon = computeMCLongitude(gmst, eq.ra);
1010
+ else if (angle === "IC") lineLon = computeICLongitude(gmst, eq.ra);
1011
+ else
1012
+ lineLon = computeHorizonLongitude(
1013
+ gmst,
1014
+ eq.ra,
1015
+ eq.dec,
1016
+ latitude,
1017
+ angle
1018
+ );
1019
+ if (lineLon === null) continue;
1020
+ const dist = geographicAngularDifference(longitude, lineLon);
1021
+ lines.push({
1022
+ planet: name,
1023
+ angle,
1024
+ distance: Math.round(dist * 1e3) / 1e3,
1025
+ active: dist <= orb,
1026
+ longitude: Math.round(lineLon * 1e3) / 1e3
1027
+ });
1028
+ }
1029
+ }
1030
+ lines.sort((a, b) => a.distance - b.distance);
1031
+ const activeLines = lines.filter((l) => l.active);
1032
+ const parans = findParansAtLatitude(positions, gmst, latitude, paranOrb);
1033
+ return { queryLatitude: latitude, queryLongitude: longitude, orb, lines, activeLines, parans };
1034
+ }
1035
+ function computeAstrocartographyMap(date, options = {}) {
1036
+ const {
1037
+ latitudeStep = 1,
1038
+ latitudeRange = 66.5,
1039
+ planets = ASTROCARTOGRAPHY_DEFAULT_PLANETS
1040
+ } = options;
1041
+ const jd = getJulianDay(date);
1042
+ const gmst = computeGMST(jd);
1043
+ const positions = computeEquatorialPositions(date, planets);
1044
+ const meridianLines = [];
1045
+ const horizonLines = [];
1046
+ for (const [name, eq] of Object.entries(positions)) {
1047
+ meridianLines.push({
1048
+ planet: name,
1049
+ angle: "MC",
1050
+ longitude: Math.round(computeMCLongitude(gmst, eq.ra) * 1e3) / 1e3
1051
+ });
1052
+ meridianLines.push({
1053
+ planet: name,
1054
+ angle: "IC",
1055
+ longitude: Math.round(computeICLongitude(gmst, eq.ra) * 1e3) / 1e3
1056
+ });
1057
+ for (const angle of ["AC", "DC"]) {
1058
+ const points = [];
1059
+ for (let lat = -latitudeRange; lat <= latitudeRange; lat += latitudeStep) {
1060
+ const lon = computeHorizonLongitude(gmst, eq.ra, eq.dec, lat, angle);
1061
+ if (lon !== null) {
1062
+ points.push({
1063
+ latitude: Math.round(lat * 1e3) / 1e3,
1064
+ longitude: Math.round(lon * 1e3) / 1e3
1065
+ });
1066
+ }
1067
+ }
1068
+ horizonLines.push({ planet: name, angle, points });
1069
+ }
1070
+ }
1071
+ return { meridianLines, horizonLines };
1072
+ }
1073
+
759
1074
  // src/astrology/aspects.ts
760
1075
  var DEFAULT_ASPECT_SPECS = [
761
1076
  { name: "conjunction", angle: 0, orb: 8 },
@@ -1670,6 +1985,6 @@ async function getSolarReturnChart(options) {
1670
1985
  };
1671
1986
  }
1672
1987
 
1673
- export { CalcFlag, DEFAULT_ASPECT_SPECS, DOMICILE_RULERS, EXALTATIONS, HouseSystem, PLANET_AND_NODE_NAMES, Planet, SIGNS, SLOW_PLANETS, VirtualNodes, closeSwissEph, computeAspects, computeMidpoints, computeSynastryAspects, computeTransitAspects, findHouseOf, formatDegreeMinutes, getAnnualProfection, getAspectMatch, getBirthChart, getCompositeChart, getDecan, getDetriment, getDodecatemoria, getDomicileRuler, getEssentialDignity, getExaltation, getFall, getFirdaria, getMonthlyProfections, getOppositeSign, getSolarReturnChart, getSwissEph, getSynastryChart, getTransitChart, getTransitRange, getZodiacPosition, normalizeAngle, shorterArcMidpoint };
1674
- //# sourceMappingURL=chunk-EBLM443L.mjs.map
1675
- //# sourceMappingURL=chunk-EBLM443L.mjs.map
1988
+ export { ASTROCARTOGRAPHY_DEFAULT_PLANETS, CalcFlag, DEFAULT_ASPECT_SPECS, DOMICILE_RULERS, EXALTATIONS, HouseSystem, PLANET_AND_NODE_NAMES, Planet, RiseTransitFlag, SIGNS, SLOW_PLANETS, VirtualNodes, closeSwissEph, computeAspects, computeAstrocartographyMap, computeEquatorialPositions, computeGMST, computeHorizonLongitude, computeICLongitude, computeMCLongitude, computeMidpoints, computeSynastryAspects, computeTransitAspects, findHouseOf, findParansAtLatitude, formatDegreeMinutes, geographicAngularDifference, getAnnualProfection, getAspectMatch, getBirthChart, getCompositeChart, getDecan, getDetriment, getDodecatemoria, getDomicileRuler, getEssentialDignity, getExaltation, getFall, getFirdaria, getMonthlyProfections, getOppositeSign, getSolarReturnChart, getSwissEph, getSynastryChart, getTransitChart, getTransitRange, getZodiacPosition, normalizeAngle, queryAstrocartographyLocation, shorterArcMidpoint };
1989
+ //# sourceMappingURL=chunk-T6Y4DLMA.mjs.map
1990
+ //# sourceMappingURL=chunk-T6Y4DLMA.mjs.map