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