panchang-ts 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -102
- package/dist/index.cjs +22 -133
- package/dist/index.d.cts +1 -77
- package/dist/index.d.ts +1 -77
- package/dist/index.js +23 -132
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ Works offline in React Native (Hermes), Node.js, and browsers.
|
|
|
22
22
|
- **Instant mode:** Elements active at an exact moment (birth charts, muhurta selection)
|
|
23
23
|
- **3 ayanamsa systems:** Lahiri (default), B.V. Raman, KP (Krishnamurti)
|
|
24
24
|
- **3 languages:** English, Sanskrit (Devanagari), Hindi
|
|
25
|
-
- **Jyotish (Vedic astrology):**
|
|
25
|
+
- **Jyotish (Vedic astrology):** All 9 graha positions (geocentric, sidereal), Vimshottari Dasha with Antardasha breakdown
|
|
26
26
|
- **React Native compatible:** Pure JS math, no native modules, tested on Hermes
|
|
27
27
|
- **Fast:** ~0.1 ms names-only on Node.js; <100 ms on budget Android (Hermes)
|
|
28
28
|
- **Typed:** Full TypeScript types for every result and option
|
|
@@ -186,77 +186,6 @@ const result = getDailyPanchang(
|
|
|
186
186
|
|
|
187
187
|
---
|
|
188
188
|
|
|
189
|
-
### `computeKundli(birthDateUtc, location, options?)`
|
|
190
|
-
|
|
191
|
-
Compute a complete Janam Kundli (Vedic birth chart).
|
|
192
|
-
|
|
193
|
-
```typescript
|
|
194
|
-
import { computeKundli } from 'panchang-ts';
|
|
195
|
-
|
|
196
|
-
const kundli = computeKundli(
|
|
197
|
-
new Date('1990-06-15T08:30:00Z'), // UTC birth moment
|
|
198
|
-
{ latitude: 18.5204, longitude: 73.8567 }, // birth location
|
|
199
|
-
{ ayanamsa: 'lahiri', language: 'en' },
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
// Ascendant
|
|
203
|
-
console.log(kundli.lagna.name); // "Karka" (Cancer)
|
|
204
|
-
console.log(kundli.lagnaLongitude); // 95.4 (sidereal degrees)
|
|
205
|
-
|
|
206
|
-
// Planetary positions
|
|
207
|
-
const sun = kundli.grahas.sun;
|
|
208
|
-
console.log(sun.rashi.name); // "Mithuna"
|
|
209
|
-
console.log(sun.nakshatra.name); // "Ardra"
|
|
210
|
-
console.log(sun.degreeInRashi); // 24.3
|
|
211
|
-
console.log(sun.isRetrograde); // false
|
|
212
|
-
|
|
213
|
-
// Houses (whole-sign)
|
|
214
|
-
kundli.houses.forEach(h => {
|
|
215
|
-
console.log(`House ${h.number}: ${h.rashi.name} — ${h.planets.join(', ')}`);
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
// Navamsa (D-9) chart
|
|
219
|
-
console.log(kundli.navamsa.lagna.name); // Navamsa lagna sign
|
|
220
|
-
kundli.navamsa.positions.forEach(p => {
|
|
221
|
-
console.log(p.planet, '→', p.rashi.name);
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
// Vimshottari Dasha
|
|
225
|
-
const dasha = kundli.dasha;
|
|
226
|
-
console.log(dasha.currentMahaDashaLord); // e.g. "Jupiter"
|
|
227
|
-
dasha.mahaDashas.forEach(md => {
|
|
228
|
-
console.log(md.lord, md.startDate, '→', md.endDate, `(${md.years}y)`);
|
|
229
|
-
md.antarDashas.forEach(ad => {
|
|
230
|
-
console.log(' ', ad.lord, ad.startDate, '→', ad.endDate);
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
// Full birth Panchang is also included
|
|
235
|
-
console.log(kundli.birthPanchang.tithi.name); // Tithi at birth
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
**Returns: `KundliResult`**
|
|
239
|
-
|
|
240
|
-
| Field | Type | Description |
|
|
241
|
-
|-------|------|-------------|
|
|
242
|
-
| `lagnaLongitude` | `number` | Sidereal longitude of the Ascendant in degrees [0, 360) |
|
|
243
|
-
| `lagna` | `RashiInfo` | Ascendant zodiac sign |
|
|
244
|
-
| `houses` | `KundliHouse[]` | 12 houses; House 1 = Lagna sign (whole-sign system) |
|
|
245
|
-
| `grahas` | `PlanetaryPositions` | All 9 graha positions with rashi, nakshatra, house, retrograde flag |
|
|
246
|
-
| `navamsa` | `NavamsaChart` | D-9 divisional chart with Lagna and all planet positions |
|
|
247
|
-
| `dasha` | `VimshottariDashaResult` | Full Vimshottari Dasha sequence from birth with Antardasha breakdown |
|
|
248
|
-
| `birthPanchang` | `InstantPanchangResult` | Complete Panchang at the birth moment |
|
|
249
|
-
|
|
250
|
-
**`KundliOptions`** (optional):
|
|
251
|
-
|
|
252
|
-
| Option | Type | Default | Description |
|
|
253
|
-
|--------|------|---------|-------------|
|
|
254
|
-
| `ayanamsa` | `'lahiri' \| 'raman' \| 'krishnamurti'` | `'lahiri'` | Ayanamsa system |
|
|
255
|
-
| `language` | `'en' \| 'sa' \| 'hi'` | `'en'` | Language for names |
|
|
256
|
-
| `computeDasha` | `boolean` | `true` | Set `false` to skip Vimshottari Dasha computation |
|
|
257
|
-
|
|
258
|
-
---
|
|
259
|
-
|
|
260
189
|
### `getInstantPanchang(date, location, options?)`
|
|
261
190
|
|
|
262
191
|
Returns the single Panchang element active at an exact UTC moment.
|
|
@@ -332,7 +261,7 @@ import {
|
|
|
332
261
|
computeAbhijitMuhurta, computeBrahmaMuhurta,
|
|
333
262
|
computeGowriPanchangam,
|
|
334
263
|
// Jyotish
|
|
335
|
-
computePlanetaryPositions, computeVimshottariDasha,
|
|
264
|
+
computePlanetaryPositions, computeVimshottariDasha,
|
|
336
265
|
GRAHA_ABBR,
|
|
337
266
|
} from 'panchang-ts';
|
|
338
267
|
|
|
@@ -374,9 +303,6 @@ console.log(grahas.jupiter.rashi.name); // e.g. "Dhanu"
|
|
|
374
303
|
console.log(grahas.saturn.isRetrograde); // true/false
|
|
375
304
|
console.log(GRAHA_ABBR['Jupiter']); // "Ju"
|
|
376
305
|
|
|
377
|
-
// Lagna (Ascendant) longitude — useful when building a custom chart renderer
|
|
378
|
-
const lagnaLon = computeLagnaLongitude(birthDate, latitude, longitude, 'lahiri');
|
|
379
|
-
|
|
380
306
|
// Vimshottari Dasha — pass birth date and Moon's sidereal longitude
|
|
381
307
|
const moonLon = getSiderealMoonLongitude(birthDate, 'lahiri');
|
|
382
308
|
const dasha = computeVimshottariDasha(birthDate, moonLon);
|
|
@@ -546,7 +472,6 @@ interface GrahaPosition {
|
|
|
546
472
|
degreeInRashi: number; // degrees within sign [0, 30)
|
|
547
473
|
nakshatra: NakshatraInfo; // nakshatra + pada + completion %
|
|
548
474
|
isRetrograde: boolean; // always false for Sun/Moon; always true for Rahu/Ketu
|
|
549
|
-
house: number; // 1–12 (whole-sign system, relative to Lagna)
|
|
550
475
|
}
|
|
551
476
|
|
|
552
477
|
interface PlanetaryPositions {
|
|
@@ -555,22 +480,6 @@ interface PlanetaryPositions {
|
|
|
555
480
|
saturn: GrahaPosition; rahu: GrahaPosition; ketu: GrahaPosition;
|
|
556
481
|
}
|
|
557
482
|
|
|
558
|
-
interface KundliHouse {
|
|
559
|
-
number: number; // 1–12
|
|
560
|
-
rashi: RashiInfo; // sign on this house cusp
|
|
561
|
-
planets: string[]; // short abbreviations: "Su", "Mo", "Ma", "Me", "Ju", "Ve", "Sa", "Ra", "Ke"
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
interface NavamsaPosition {
|
|
565
|
-
planet: GrahaName;
|
|
566
|
-
rashi: RashiInfo; // D-9 (Navamsa) sign for this planet
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
interface NavamsaChart {
|
|
570
|
-
positions: NavamsaPosition[];
|
|
571
|
-
lagna: RashiInfo; // Navamsa Lagna sign
|
|
572
|
-
}
|
|
573
|
-
|
|
574
483
|
type DashaLord = 'Ketu' | 'Venus' | 'Sun' | 'Moon' | 'Mars' | 'Rahu' | 'Jupiter' | 'Saturn' | 'Mercury';
|
|
575
484
|
|
|
576
485
|
interface AntarDasha {
|
|
@@ -593,15 +502,6 @@ interface VimshottariDashaResult {
|
|
|
593
502
|
mahaDashas: MahaDasha[]; // 9-entry sequence starting from birth
|
|
594
503
|
}
|
|
595
504
|
|
|
596
|
-
interface KundliResult {
|
|
597
|
-
lagnaLongitude: number; // sidereal ascendant in degrees [0, 360)
|
|
598
|
-
lagna: RashiInfo; // ascendant sign
|
|
599
|
-
houses: KundliHouse[]; // 12 houses (whole-sign)
|
|
600
|
-
grahas: PlanetaryPositions; // all 9 graha positions
|
|
601
|
-
navamsa: NavamsaChart; // D-9 chart
|
|
602
|
-
birthPanchang: InstantPanchangResult;
|
|
603
|
-
dasha: VimshottariDashaResult;
|
|
604
|
-
}
|
|
605
505
|
```
|
|
606
506
|
|
|
607
507
|
---
|
package/dist/index.cjs
CHANGED
|
@@ -76,6 +76,13 @@ var JUPITER_GM = 2825345909524226e-22;
|
|
|
76
76
|
var SATURN_GM = 8459715185680659e-23;
|
|
77
77
|
var URANUS_GM = 1292024916781969e-23;
|
|
78
78
|
var NEPTUNE_GM = 1524358900784276e-23;
|
|
79
|
+
function VerifyBoolean(b) {
|
|
80
|
+
if (b !== true && b !== false) {
|
|
81
|
+
console.trace();
|
|
82
|
+
throw `Value is not boolean: ${b}`;
|
|
83
|
+
}
|
|
84
|
+
return b;
|
|
85
|
+
}
|
|
79
86
|
function VerifyNumber(x) {
|
|
80
87
|
if (!Number.isFinite(x)) {
|
|
81
88
|
console.trace();
|
|
@@ -1372,10 +1379,6 @@ function sidereal_time(time) {
|
|
|
1372
1379
|
}
|
|
1373
1380
|
return sidereal_time_cache.st;
|
|
1374
1381
|
}
|
|
1375
|
-
function SiderealTime(date) {
|
|
1376
|
-
const time = MakeTime(date);
|
|
1377
|
-
return sidereal_time(time);
|
|
1378
|
-
}
|
|
1379
1382
|
function terra(observer, st) {
|
|
1380
1383
|
const phi = observer.latitude * DEG2RAD;
|
|
1381
1384
|
const sinphi = Math.sin(phi);
|
|
@@ -1598,6 +1601,8 @@ function SunPosition(date) {
|
|
|
1598
1601
|
}
|
|
1599
1602
|
function Equator(body, date, observer, ofdate, aberration) {
|
|
1600
1603
|
VerifyObserver(observer);
|
|
1604
|
+
VerifyBoolean(ofdate);
|
|
1605
|
+
VerifyBoolean(aberration);
|
|
1601
1606
|
const time = MakeTime(date);
|
|
1602
1607
|
const gc_observer = geo_pos(time, observer);
|
|
1603
1608
|
const gc = GeoVector(body, time, aberration);
|
|
@@ -2103,24 +2108,30 @@ var BodyPosition = class {
|
|
|
2103
2108
|
}
|
|
2104
2109
|
};
|
|
2105
2110
|
function BackdatePosition(date, observerBody, targetBody, aberration) {
|
|
2111
|
+
VerifyBoolean(aberration);
|
|
2106
2112
|
const time = MakeTime(date);
|
|
2107
2113
|
if (UserDefinedStar(targetBody)) {
|
|
2108
2114
|
const tvec = HelioVector(targetBody, time);
|
|
2109
|
-
{
|
|
2115
|
+
if (aberration) {
|
|
2110
2116
|
const ostate = HelioState(observerBody, time);
|
|
2111
2117
|
const rvec = new Vector(tvec.x - ostate.x, tvec.y - ostate.y, tvec.z - ostate.z, time);
|
|
2112
2118
|
const s = C_AUDAY / rvec.Length();
|
|
2113
2119
|
return new Vector(rvec.x + ostate.vx / s, rvec.y + ostate.vy / s, rvec.z + ostate.vz / s, time);
|
|
2114
2120
|
}
|
|
2121
|
+
const ovec = HelioVector(observerBody, time);
|
|
2122
|
+
return new Vector(tvec.x - ovec.x, tvec.y - ovec.y, tvec.z - ovec.z, time);
|
|
2115
2123
|
}
|
|
2116
2124
|
let observerPos;
|
|
2117
|
-
{
|
|
2125
|
+
if (aberration) {
|
|
2118
2126
|
observerPos = new Vector(0, 0, 0, time);
|
|
2127
|
+
} else {
|
|
2128
|
+
observerPos = HelioVector(observerBody, time);
|
|
2119
2129
|
}
|
|
2120
2130
|
const bpos = new BodyPosition(observerBody, targetBody, aberration, observerPos);
|
|
2121
2131
|
return CorrectLightTravel((t) => bpos.Position(t), time);
|
|
2122
2132
|
}
|
|
2123
2133
|
function GeoVector(body, date, aberration) {
|
|
2134
|
+
VerifyBoolean(aberration);
|
|
2124
2135
|
const time = MakeTime(date);
|
|
2125
2136
|
switch (body) {
|
|
2126
2137
|
case Body.Earth:
|
|
@@ -2266,13 +2277,6 @@ function Search(f, t1, t2, options) {
|
|
|
2266
2277
|
return null;
|
|
2267
2278
|
}
|
|
2268
2279
|
}
|
|
2269
|
-
function EclipticLongitude(body, date) {
|
|
2270
|
-
if (body === Body.Sun)
|
|
2271
|
-
throw "Cannot calculate heliocentric longitude of the Sun.";
|
|
2272
|
-
const hv = HelioVector(body, date);
|
|
2273
|
-
const eclip = Ecliptic(hv);
|
|
2274
|
-
return eclip.elon;
|
|
2275
|
-
}
|
|
2276
2280
|
var AtmosphereInfo = class {
|
|
2277
2281
|
constructor(pressure, temperature, density) {
|
|
2278
2282
|
this.pressure = pressure;
|
|
@@ -2541,12 +2545,6 @@ function normalize360(degrees) {
|
|
|
2541
2545
|
if (r === 0) return 0;
|
|
2542
2546
|
return r < 0 ? r + 360 : r;
|
|
2543
2547
|
}
|
|
2544
|
-
function degToRad(degrees) {
|
|
2545
|
-
return degrees * (Math.PI / 180);
|
|
2546
|
-
}
|
|
2547
|
-
function radToDeg(radians) {
|
|
2548
|
-
return radians * (180 / Math.PI);
|
|
2549
|
-
}
|
|
2550
2548
|
|
|
2551
2549
|
// src/astronomy/moon.ts
|
|
2552
2550
|
function getSiderealMoonLongitude(date, ayanamsaType) {
|
|
@@ -4024,16 +4022,14 @@ var GRAHA_ABBR = {
|
|
|
4024
4022
|
Rahu: "Ra",
|
|
4025
4023
|
Ketu: "Ke"
|
|
4026
4024
|
};
|
|
4027
|
-
function meanObliquity(T) {
|
|
4028
|
-
return 23.439291111 - 0.013004167 * T - 164e-9 * T * T + 504e-9 * T * T * T;
|
|
4029
|
-
}
|
|
4030
4025
|
function getTropicalPlanetLongitude(body, date) {
|
|
4031
|
-
|
|
4026
|
+
const vec = GeoVector(body, MakeTime(date), true);
|
|
4027
|
+
return Ecliptic(vec).elon;
|
|
4032
4028
|
}
|
|
4033
4029
|
function isRetrograde(body, date) {
|
|
4034
4030
|
const dt = 36e5;
|
|
4035
|
-
const lon0 =
|
|
4036
|
-
const lon1 =
|
|
4031
|
+
const lon0 = Ecliptic(GeoVector(body, MakeTime(new Date(date.getTime() - dt)), false)).elon;
|
|
4032
|
+
const lon1 = Ecliptic(GeoVector(body, MakeTime(new Date(date.getTime() + dt)), false)).elon;
|
|
4037
4033
|
let delta = lon1 - lon0;
|
|
4038
4034
|
if (delta > 180) delta -= 360;
|
|
4039
4035
|
if (delta < -180) delta += 360;
|
|
@@ -4059,9 +4055,7 @@ function buildGrahaPosition(planet, siderealLon, isRetro, nakshatraNameFn, rashi
|
|
|
4059
4055
|
rashi: { index: rashiIndex, name: rashiNameFn(rashiIndex) },
|
|
4060
4056
|
degreeInRashi,
|
|
4061
4057
|
nakshatra: computeNakshatraFromLongitude(siderealLon, nakshatraNameFn(nakIdx)),
|
|
4062
|
-
isRetrograde: isRetro
|
|
4063
|
-
house: 0
|
|
4064
|
-
// assigned later in computeKundli
|
|
4058
|
+
isRetrograde: isRetro
|
|
4065
4059
|
};
|
|
4066
4060
|
}
|
|
4067
4061
|
var identity = (idx) => String(idx);
|
|
@@ -4097,41 +4091,6 @@ function computePlanetaryPositions(date, ayanamsaType, nakshatraName = identity,
|
|
|
4097
4091
|
};
|
|
4098
4092
|
}
|
|
4099
4093
|
|
|
4100
|
-
// src/jyotish/lagna.ts
|
|
4101
|
-
function computeLagnaLongitude(date, latitude, longitude, ayanamsaType) {
|
|
4102
|
-
const gastHours = SiderealTime(MakeTime(date));
|
|
4103
|
-
const last_deg = normalize360(gastHours * 15 + longitude);
|
|
4104
|
-
const T = (dateToJulianDay(date) - 2451545) / 36525;
|
|
4105
|
-
const eps_deg = meanObliquity(T);
|
|
4106
|
-
const ramc = degToRad(last_deg);
|
|
4107
|
-
const eps = degToRad(eps_deg);
|
|
4108
|
-
const phi = degToRad(latitude);
|
|
4109
|
-
const y = -Math.cos(ramc);
|
|
4110
|
-
const x = Math.sin(ramc) * Math.cos(eps) + Math.tan(phi) * Math.sin(eps);
|
|
4111
|
-
let tropicalAsc = normalize360(radToDeg(Math.atan2(y, x)));
|
|
4112
|
-
const mcRaw = radToDeg(Math.atan2(Math.tan(ramc), Math.cos(eps)));
|
|
4113
|
-
const mc = normalize360(
|
|
4114
|
-
last_deg < 180 ? normalize360(mcRaw) : normalize360(mcRaw + 180)
|
|
4115
|
-
);
|
|
4116
|
-
const diff = normalize360(tropicalAsc - mc);
|
|
4117
|
-
if (diff < 90 || diff > 270) {
|
|
4118
|
-
tropicalAsc = normalize360(tropicalAsc + 180);
|
|
4119
|
-
}
|
|
4120
|
-
const ayanamsa = computeAyanamsa(date, ayanamsaType);
|
|
4121
|
-
return normalize360(tropicalAsc - ayanamsa);
|
|
4122
|
-
}
|
|
4123
|
-
function navamsaRashi(siderealLongitude) {
|
|
4124
|
-
const rashiIdx = Math.floor(siderealLongitude / 30);
|
|
4125
|
-
const degInRashi = siderealLongitude - rashiIdx * 30;
|
|
4126
|
-
const navamsaIndex = Math.floor(degInRashi / (30 / 9));
|
|
4127
|
-
const NAVAMSA_STARTS = [0, 9, 6, 3, 0, 9, 6, 3, 0, 9, 6, 3];
|
|
4128
|
-
return (NAVAMSA_STARTS[rashiIdx] + navamsaIndex) % 12;
|
|
4129
|
-
}
|
|
4130
|
-
function rashiFromLongitude(lon, nameFn) {
|
|
4131
|
-
const index = Math.floor(lon / 30);
|
|
4132
|
-
return { index, name: nameFn(index) };
|
|
4133
|
-
}
|
|
4134
|
-
|
|
4135
4094
|
// src/jyotish/dasha.ts
|
|
4136
4095
|
var DASHA_YEARS = {
|
|
4137
4096
|
Ketu: 7,
|
|
@@ -4232,74 +4191,6 @@ function buildAntarDashas(mahaLord, mahaStart, mahaDurationMs) {
|
|
|
4232
4191
|
}
|
|
4233
4192
|
return antarDashas;
|
|
4234
4193
|
}
|
|
4235
|
-
|
|
4236
|
-
// src/jyotish/kundli.ts
|
|
4237
|
-
function computeKundli(birthDateUtc, location, options) {
|
|
4238
|
-
validateDate(birthDateUtc);
|
|
4239
|
-
validateLocation(location);
|
|
4240
|
-
const ayanamsa = options?.ayanamsa ?? "lahiri";
|
|
4241
|
-
const lang = options?.language ?? "en";
|
|
4242
|
-
const doDasha = options?.computeDasha !== false;
|
|
4243
|
-
const rashiName = (idx) => resolveMasaName(idx, lang);
|
|
4244
|
-
const nakshatraName = (idx) => resolveNakshatraName(idx, lang);
|
|
4245
|
-
const birthPanchang = getInstantPanchang(birthDateUtc, location, {
|
|
4246
|
-
ayanamsa,
|
|
4247
|
-
language: lang,
|
|
4248
|
-
computeEndTimes: options?.computeEndTimes ?? false,
|
|
4249
|
-
precision: options?.precision
|
|
4250
|
-
});
|
|
4251
|
-
const grahas = computePlanetaryPositions(birthDateUtc, ayanamsa, nakshatraName, rashiName);
|
|
4252
|
-
const lagnaLon = computeLagnaLongitude(
|
|
4253
|
-
birthDateUtc,
|
|
4254
|
-
location.latitude,
|
|
4255
|
-
location.longitude,
|
|
4256
|
-
ayanamsa
|
|
4257
|
-
);
|
|
4258
|
-
const lagna = rashiFromLongitude(lagnaLon, rashiName);
|
|
4259
|
-
const lagnaRashiIdx = lagna.index;
|
|
4260
|
-
const houses = Array.from({ length: 12 }, (_, i) => {
|
|
4261
|
-
const houseRashiIdx = (lagnaRashiIdx + i) % 12;
|
|
4262
|
-
return {
|
|
4263
|
-
number: i + 1,
|
|
4264
|
-
rashi: { index: houseRashiIdx, name: rashiName(houseRashiIdx) },
|
|
4265
|
-
planets: []
|
|
4266
|
-
};
|
|
4267
|
-
});
|
|
4268
|
-
const grahaList = Object.values(grahas);
|
|
4269
|
-
for (const graha of grahaList) {
|
|
4270
|
-
const houseNumber = (graha.rashi.index - lagnaRashiIdx + 12) % 12 + 1;
|
|
4271
|
-
graha.house = houseNumber;
|
|
4272
|
-
houses[houseNumber - 1].planets.push(GRAHA_ABBR[graha.planet]);
|
|
4273
|
-
}
|
|
4274
|
-
const navamsa = buildNavamsaChart(grahas, lagnaLon, rashiName);
|
|
4275
|
-
const dasha = doDasha ? computeVimshottariDasha(birthDateUtc, birthPanchang.siderealMoon) : { currentMahaDashaLord: "Sun", currentIndex: 0, mahaDashas: [] };
|
|
4276
|
-
return {
|
|
4277
|
-
lagnaLongitude: lagnaLon,
|
|
4278
|
-
lagna,
|
|
4279
|
-
houses,
|
|
4280
|
-
grahas,
|
|
4281
|
-
navamsa,
|
|
4282
|
-
birthPanchang,
|
|
4283
|
-
dasha
|
|
4284
|
-
};
|
|
4285
|
-
}
|
|
4286
|
-
function buildNavamsaChart(grahas, lagnaLon, rashiName) {
|
|
4287
|
-
const grahaList = Object.values(grahas);
|
|
4288
|
-
const positions = grahaList.map((g) => ({
|
|
4289
|
-
planet: g.planet,
|
|
4290
|
-
rashi: {
|
|
4291
|
-
index: navamsaRashi(g.siderealLongitude),
|
|
4292
|
-
name: rashiName(navamsaRashi(g.siderealLongitude))
|
|
4293
|
-
}
|
|
4294
|
-
}));
|
|
4295
|
-
return {
|
|
4296
|
-
positions,
|
|
4297
|
-
lagna: {
|
|
4298
|
-
index: navamsaRashi(lagnaLon),
|
|
4299
|
-
name: rashiName(navamsaRashi(lagnaLon))
|
|
4300
|
-
}
|
|
4301
|
-
};
|
|
4302
|
-
}
|
|
4303
4194
|
/*! Bundled license information:
|
|
4304
4195
|
|
|
4305
4196
|
astronomy-engine/esm/astronomy.js:
|
|
@@ -4344,8 +4235,6 @@ exports.computeAbhijitMuhurta = computeAbhijitMuhurta;
|
|
|
4344
4235
|
exports.computeBrahmaMuhurta = computeBrahmaMuhurta;
|
|
4345
4236
|
exports.computeGowriPanchangam = computeGowriPanchangam;
|
|
4346
4237
|
exports.computeGulikaKalam = computeGulikaKalam;
|
|
4347
|
-
exports.computeKundli = computeKundli;
|
|
4348
|
-
exports.computeLagnaLongitude = computeLagnaLongitude;
|
|
4349
4238
|
exports.computePlanetaryPositions = computePlanetaryPositions;
|
|
4350
4239
|
exports.computeRahuKalam = computeRahuKalam;
|
|
4351
4240
|
exports.computeVimshottariDasha = computeVimshottariDasha;
|
package/dist/index.d.cts
CHANGED
|
@@ -295,8 +295,6 @@ interface GrahaPosition {
|
|
|
295
295
|
* Rahu/Ketu are always retrograde by definition.
|
|
296
296
|
*/
|
|
297
297
|
isRetrograde: boolean;
|
|
298
|
-
/** 1-based house number where this planet sits (set after house assignment) */
|
|
299
|
-
house: number;
|
|
300
298
|
}
|
|
301
299
|
interface PlanetaryPositions {
|
|
302
300
|
sun: GrahaPosition;
|
|
@@ -309,40 +307,6 @@ interface PlanetaryPositions {
|
|
|
309
307
|
rahu: GrahaPosition;
|
|
310
308
|
ketu: GrahaPosition;
|
|
311
309
|
}
|
|
312
|
-
interface KundliHouse {
|
|
313
|
-
/** 1–12 */
|
|
314
|
-
number: number;
|
|
315
|
-
/** Zodiac sign on the cusp of this house */
|
|
316
|
-
rashi: RashiInfo;
|
|
317
|
-
/** Short planet abbreviations occupying this house (e.g. "Su", "Mo") */
|
|
318
|
-
planets: string[];
|
|
319
|
-
}
|
|
320
|
-
interface NavamsaPosition {
|
|
321
|
-
planet: GrahaName;
|
|
322
|
-
/** Navamsa rashi (D-9 sign) */
|
|
323
|
-
rashi: RashiInfo;
|
|
324
|
-
}
|
|
325
|
-
interface NavamsaChart {
|
|
326
|
-
positions: NavamsaPosition[];
|
|
327
|
-
/** Navamsa Lagna rashi */
|
|
328
|
-
lagna: RashiInfo;
|
|
329
|
-
}
|
|
330
|
-
interface KundliResult {
|
|
331
|
-
/** Sidereal longitude of the Ascendant in degrees [0, 360) */
|
|
332
|
-
lagnaLongitude: number;
|
|
333
|
-
/** Ascendant sign */
|
|
334
|
-
lagna: RashiInfo;
|
|
335
|
-
/** 12 houses, 1st house = lagna sign */
|
|
336
|
-
houses: KundliHouse[];
|
|
337
|
-
/** All 9 graha positions with house assignments */
|
|
338
|
-
grahas: PlanetaryPositions;
|
|
339
|
-
/** Navamsa (D-9) divisional chart */
|
|
340
|
-
navamsa: NavamsaChart;
|
|
341
|
-
/** Full Panchang at the birth moment */
|
|
342
|
-
birthPanchang: InstantPanchangResult;
|
|
343
|
-
/** Vimshottari Dasha from birth */
|
|
344
|
-
dasha: VimshottariDashaResult;
|
|
345
|
-
}
|
|
346
310
|
type DashaLord = 'Ketu' | 'Venus' | 'Sun' | 'Moon' | 'Mars' | 'Rahu' | 'Jupiter' | 'Saturn' | 'Mercury';
|
|
347
311
|
interface AntarDasha {
|
|
348
312
|
lord: DashaLord;
|
|
@@ -369,26 +333,6 @@ interface VimshottariDashaResult {
|
|
|
369
333
|
mahaDashas: MahaDasha[];
|
|
370
334
|
}
|
|
371
335
|
|
|
372
|
-
interface KundliOptions extends InstantPanchangOptions {
|
|
373
|
-
/**
|
|
374
|
-
* When true, compute Vimshottari Dasha periods.
|
|
375
|
-
* Slightly more expensive. Default: true.
|
|
376
|
-
*/
|
|
377
|
-
computeDasha?: boolean;
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* Compute a complete Janam Kundli (birth chart).
|
|
381
|
-
*
|
|
382
|
-
* Returns planetary positions, Lagna, 12 houses, Navamsa (D-9) chart,
|
|
383
|
-
* Vimshottari Dasha periods, and the full birth Panchang.
|
|
384
|
-
*
|
|
385
|
-
* @param birthDateUtc UTC birth moment. For times stored as "local time in UTC"
|
|
386
|
-
* (the panchang-ts convention), pass the Date as-is.
|
|
387
|
-
* @param location Birth location coordinates.
|
|
388
|
-
* @param options Optional ayanamsa, language, computeDasha flag.
|
|
389
|
-
*/
|
|
390
|
-
declare function computeKundli(birthDateUtc: Date, location: GeoLocation, options?: KundliOptions): KundliResult;
|
|
391
|
-
|
|
392
336
|
declare const GRAHA_ABBR: Record<GrahaName, string>;
|
|
393
337
|
/**
|
|
394
338
|
* Compute geocentric sidereal positions for all 9 grahas.
|
|
@@ -408,26 +352,6 @@ declare function computePlanetaryPositions(date: Date, ayanamsaType: AyanamsaTyp
|
|
|
408
352
|
*/
|
|
409
353
|
declare function computeVimshottariDasha(birthDate: Date, moonSiderealLon: number): VimshottariDashaResult;
|
|
410
354
|
|
|
411
|
-
/**
|
|
412
|
-
* Compute the sidereal longitude of the Lagna (Ascendant) for a given
|
|
413
|
-
* UTC birth time and observer location.
|
|
414
|
-
*
|
|
415
|
-
* Algorithm (Meeus, Astronomical Algorithms, Ch. 14):
|
|
416
|
-
* 1. GAST = SiderealTime(date) in hours → degrees
|
|
417
|
-
* 2. LAST = GAST + observerLongitude (in degrees)
|
|
418
|
-
* 3. RAMC = LAST (Right Ascension of the Midheaven Culminating)
|
|
419
|
-
* 4. tan(λ_asc) = -cos(RAMC) / (sin(RAMC)·cos(ε) + tan(φ)·sin(ε))
|
|
420
|
-
* where ε = mean obliquity, φ = geographic latitude
|
|
421
|
-
* 5. Sidereal Lagna = normalize(λ_asc − ayanamsa)
|
|
422
|
-
*
|
|
423
|
-
* @param date UTC birth moment.
|
|
424
|
-
* @param latitude Observer geographic latitude in degrees (−90 to +90).
|
|
425
|
-
* @param longitude Observer geographic longitude in degrees (−180 to +180).
|
|
426
|
-
* @param ayanamsaType Ayanamsa correction system.
|
|
427
|
-
* @returns Sidereal ascendant longitude [0, 360).
|
|
428
|
-
*/
|
|
429
|
-
declare function computeLagnaLongitude(date: Date, latitude: number, longitude: number, ayanamsaType: AyanamsaType): number;
|
|
430
|
-
|
|
431
355
|
/**
|
|
432
356
|
* Compute sunrise nearest to (and after) the given UTC search start.
|
|
433
357
|
*
|
|
@@ -587,4 +511,4 @@ declare class PanchangError extends Error {
|
|
|
587
511
|
constructor(message: string, code: PanchangErrorCode);
|
|
588
512
|
}
|
|
589
513
|
|
|
590
|
-
export { type AntarDasha, type AyanamsaType, type ChandraMasaInfo, type ChoghadiyaInfo, type ChoghadiyaQuality, type ChoghadiyaSlot, type DailyKaranaInfo, type DailyNakshatraInfo, type DailyPanchangResult, type DailyTithiInfo, type DailyYogaInfo, type DashaLord, type FestivalInfo, GRAHA_ABBR, type GeoLocation, type GowriInfo, type GowriSlot, type GrahaName, type GrahaPosition, type HoraInfo, type HoraSlot, type InstantPanchangOptions, type InstantPanchangResult, type KaranaInfo, type
|
|
514
|
+
export { type AntarDasha, type AyanamsaType, type ChandraMasaInfo, type ChoghadiyaInfo, type ChoghadiyaQuality, type ChoghadiyaSlot, type DailyKaranaInfo, type DailyNakshatraInfo, type DailyPanchangResult, type DailyTithiInfo, type DailyYogaInfo, type DashaLord, type FestivalInfo, GRAHA_ABBR, type GeoLocation, type GowriInfo, type GowriSlot, type GrahaName, type GrahaPosition, type HoraInfo, type HoraSlot, type InstantPanchangOptions, type InstantPanchangResult, type KaranaInfo, type Language, type MahaDasha, type MasaInfo, type NakshatraInfo, PanchangError, type PanchangErrorCode, type PanchangOptions, type PlanetaryPositions, type Precision, type RashiInfo, type SamvatInfo, type SpecialYogaInfo, type TimePeriod, type TithiInfo, type VaraInfo, type VimshottariDashaResult, type YogaInfo, computeAbhijitMuhurta, computeBrahmaMuhurta, computeGowriPanchangam, computeGulikaKalam, computePlanetaryPositions, computeRahuKalam, computeVimshottariDasha, computeYamaganda, computeAyanamsa as getAyanamsa, getDailyPanchang, getInstantPanchang, getMoonrise, getMoonset, getSiderealMoonLongitude, getSiderealSunLongitude, computeSunrise as getSunrise, computeSunset as getSunset };
|
package/dist/index.d.ts
CHANGED
|
@@ -295,8 +295,6 @@ interface GrahaPosition {
|
|
|
295
295
|
* Rahu/Ketu are always retrograde by definition.
|
|
296
296
|
*/
|
|
297
297
|
isRetrograde: boolean;
|
|
298
|
-
/** 1-based house number where this planet sits (set after house assignment) */
|
|
299
|
-
house: number;
|
|
300
298
|
}
|
|
301
299
|
interface PlanetaryPositions {
|
|
302
300
|
sun: GrahaPosition;
|
|
@@ -309,40 +307,6 @@ interface PlanetaryPositions {
|
|
|
309
307
|
rahu: GrahaPosition;
|
|
310
308
|
ketu: GrahaPosition;
|
|
311
309
|
}
|
|
312
|
-
interface KundliHouse {
|
|
313
|
-
/** 1–12 */
|
|
314
|
-
number: number;
|
|
315
|
-
/** Zodiac sign on the cusp of this house */
|
|
316
|
-
rashi: RashiInfo;
|
|
317
|
-
/** Short planet abbreviations occupying this house (e.g. "Su", "Mo") */
|
|
318
|
-
planets: string[];
|
|
319
|
-
}
|
|
320
|
-
interface NavamsaPosition {
|
|
321
|
-
planet: GrahaName;
|
|
322
|
-
/** Navamsa rashi (D-9 sign) */
|
|
323
|
-
rashi: RashiInfo;
|
|
324
|
-
}
|
|
325
|
-
interface NavamsaChart {
|
|
326
|
-
positions: NavamsaPosition[];
|
|
327
|
-
/** Navamsa Lagna rashi */
|
|
328
|
-
lagna: RashiInfo;
|
|
329
|
-
}
|
|
330
|
-
interface KundliResult {
|
|
331
|
-
/** Sidereal longitude of the Ascendant in degrees [0, 360) */
|
|
332
|
-
lagnaLongitude: number;
|
|
333
|
-
/** Ascendant sign */
|
|
334
|
-
lagna: RashiInfo;
|
|
335
|
-
/** 12 houses, 1st house = lagna sign */
|
|
336
|
-
houses: KundliHouse[];
|
|
337
|
-
/** All 9 graha positions with house assignments */
|
|
338
|
-
grahas: PlanetaryPositions;
|
|
339
|
-
/** Navamsa (D-9) divisional chart */
|
|
340
|
-
navamsa: NavamsaChart;
|
|
341
|
-
/** Full Panchang at the birth moment */
|
|
342
|
-
birthPanchang: InstantPanchangResult;
|
|
343
|
-
/** Vimshottari Dasha from birth */
|
|
344
|
-
dasha: VimshottariDashaResult;
|
|
345
|
-
}
|
|
346
310
|
type DashaLord = 'Ketu' | 'Venus' | 'Sun' | 'Moon' | 'Mars' | 'Rahu' | 'Jupiter' | 'Saturn' | 'Mercury';
|
|
347
311
|
interface AntarDasha {
|
|
348
312
|
lord: DashaLord;
|
|
@@ -369,26 +333,6 @@ interface VimshottariDashaResult {
|
|
|
369
333
|
mahaDashas: MahaDasha[];
|
|
370
334
|
}
|
|
371
335
|
|
|
372
|
-
interface KundliOptions extends InstantPanchangOptions {
|
|
373
|
-
/**
|
|
374
|
-
* When true, compute Vimshottari Dasha periods.
|
|
375
|
-
* Slightly more expensive. Default: true.
|
|
376
|
-
*/
|
|
377
|
-
computeDasha?: boolean;
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* Compute a complete Janam Kundli (birth chart).
|
|
381
|
-
*
|
|
382
|
-
* Returns planetary positions, Lagna, 12 houses, Navamsa (D-9) chart,
|
|
383
|
-
* Vimshottari Dasha periods, and the full birth Panchang.
|
|
384
|
-
*
|
|
385
|
-
* @param birthDateUtc UTC birth moment. For times stored as "local time in UTC"
|
|
386
|
-
* (the panchang-ts convention), pass the Date as-is.
|
|
387
|
-
* @param location Birth location coordinates.
|
|
388
|
-
* @param options Optional ayanamsa, language, computeDasha flag.
|
|
389
|
-
*/
|
|
390
|
-
declare function computeKundli(birthDateUtc: Date, location: GeoLocation, options?: KundliOptions): KundliResult;
|
|
391
|
-
|
|
392
336
|
declare const GRAHA_ABBR: Record<GrahaName, string>;
|
|
393
337
|
/**
|
|
394
338
|
* Compute geocentric sidereal positions for all 9 grahas.
|
|
@@ -408,26 +352,6 @@ declare function computePlanetaryPositions(date: Date, ayanamsaType: AyanamsaTyp
|
|
|
408
352
|
*/
|
|
409
353
|
declare function computeVimshottariDasha(birthDate: Date, moonSiderealLon: number): VimshottariDashaResult;
|
|
410
354
|
|
|
411
|
-
/**
|
|
412
|
-
* Compute the sidereal longitude of the Lagna (Ascendant) for a given
|
|
413
|
-
* UTC birth time and observer location.
|
|
414
|
-
*
|
|
415
|
-
* Algorithm (Meeus, Astronomical Algorithms, Ch. 14):
|
|
416
|
-
* 1. GAST = SiderealTime(date) in hours → degrees
|
|
417
|
-
* 2. LAST = GAST + observerLongitude (in degrees)
|
|
418
|
-
* 3. RAMC = LAST (Right Ascension of the Midheaven Culminating)
|
|
419
|
-
* 4. tan(λ_asc) = -cos(RAMC) / (sin(RAMC)·cos(ε) + tan(φ)·sin(ε))
|
|
420
|
-
* where ε = mean obliquity, φ = geographic latitude
|
|
421
|
-
* 5. Sidereal Lagna = normalize(λ_asc − ayanamsa)
|
|
422
|
-
*
|
|
423
|
-
* @param date UTC birth moment.
|
|
424
|
-
* @param latitude Observer geographic latitude in degrees (−90 to +90).
|
|
425
|
-
* @param longitude Observer geographic longitude in degrees (−180 to +180).
|
|
426
|
-
* @param ayanamsaType Ayanamsa correction system.
|
|
427
|
-
* @returns Sidereal ascendant longitude [0, 360).
|
|
428
|
-
*/
|
|
429
|
-
declare function computeLagnaLongitude(date: Date, latitude: number, longitude: number, ayanamsaType: AyanamsaType): number;
|
|
430
|
-
|
|
431
355
|
/**
|
|
432
356
|
* Compute sunrise nearest to (and after) the given UTC search start.
|
|
433
357
|
*
|
|
@@ -587,4 +511,4 @@ declare class PanchangError extends Error {
|
|
|
587
511
|
constructor(message: string, code: PanchangErrorCode);
|
|
588
512
|
}
|
|
589
513
|
|
|
590
|
-
export { type AntarDasha, type AyanamsaType, type ChandraMasaInfo, type ChoghadiyaInfo, type ChoghadiyaQuality, type ChoghadiyaSlot, type DailyKaranaInfo, type DailyNakshatraInfo, type DailyPanchangResult, type DailyTithiInfo, type DailyYogaInfo, type DashaLord, type FestivalInfo, GRAHA_ABBR, type GeoLocation, type GowriInfo, type GowriSlot, type GrahaName, type GrahaPosition, type HoraInfo, type HoraSlot, type InstantPanchangOptions, type InstantPanchangResult, type KaranaInfo, type
|
|
514
|
+
export { type AntarDasha, type AyanamsaType, type ChandraMasaInfo, type ChoghadiyaInfo, type ChoghadiyaQuality, type ChoghadiyaSlot, type DailyKaranaInfo, type DailyNakshatraInfo, type DailyPanchangResult, type DailyTithiInfo, type DailyYogaInfo, type DashaLord, type FestivalInfo, GRAHA_ABBR, type GeoLocation, type GowriInfo, type GowriSlot, type GrahaName, type GrahaPosition, type HoraInfo, type HoraSlot, type InstantPanchangOptions, type InstantPanchangResult, type KaranaInfo, type Language, type MahaDasha, type MasaInfo, type NakshatraInfo, PanchangError, type PanchangErrorCode, type PanchangOptions, type PlanetaryPositions, type Precision, type RashiInfo, type SamvatInfo, type SpecialYogaInfo, type TimePeriod, type TithiInfo, type VaraInfo, type VimshottariDashaResult, type YogaInfo, computeAbhijitMuhurta, computeBrahmaMuhurta, computeGowriPanchangam, computeGulikaKalam, computePlanetaryPositions, computeRahuKalam, computeVimshottariDasha, computeYamaganda, computeAyanamsa as getAyanamsa, getDailyPanchang, getInstantPanchang, getMoonrise, getMoonset, getSiderealMoonLongitude, getSiderealSunLongitude, computeSunrise as getSunrise, computeSunset as getSunset };
|
package/dist/index.js
CHANGED
|
@@ -74,6 +74,13 @@ var JUPITER_GM = 2825345909524226e-22;
|
|
|
74
74
|
var SATURN_GM = 8459715185680659e-23;
|
|
75
75
|
var URANUS_GM = 1292024916781969e-23;
|
|
76
76
|
var NEPTUNE_GM = 1524358900784276e-23;
|
|
77
|
+
function VerifyBoolean(b) {
|
|
78
|
+
if (b !== true && b !== false) {
|
|
79
|
+
console.trace();
|
|
80
|
+
throw `Value is not boolean: ${b}`;
|
|
81
|
+
}
|
|
82
|
+
return b;
|
|
83
|
+
}
|
|
77
84
|
function VerifyNumber(x) {
|
|
78
85
|
if (!Number.isFinite(x)) {
|
|
79
86
|
console.trace();
|
|
@@ -1370,10 +1377,6 @@ function sidereal_time(time) {
|
|
|
1370
1377
|
}
|
|
1371
1378
|
return sidereal_time_cache.st;
|
|
1372
1379
|
}
|
|
1373
|
-
function SiderealTime(date) {
|
|
1374
|
-
const time = MakeTime(date);
|
|
1375
|
-
return sidereal_time(time);
|
|
1376
|
-
}
|
|
1377
1380
|
function terra(observer, st) {
|
|
1378
1381
|
const phi = observer.latitude * DEG2RAD;
|
|
1379
1382
|
const sinphi = Math.sin(phi);
|
|
@@ -1596,6 +1599,8 @@ function SunPosition(date) {
|
|
|
1596
1599
|
}
|
|
1597
1600
|
function Equator(body, date, observer, ofdate, aberration) {
|
|
1598
1601
|
VerifyObserver(observer);
|
|
1602
|
+
VerifyBoolean(ofdate);
|
|
1603
|
+
VerifyBoolean(aberration);
|
|
1599
1604
|
const time = MakeTime(date);
|
|
1600
1605
|
const gc_observer = geo_pos(time, observer);
|
|
1601
1606
|
const gc = GeoVector(body, time, aberration);
|
|
@@ -2101,24 +2106,30 @@ var BodyPosition = class {
|
|
|
2101
2106
|
}
|
|
2102
2107
|
};
|
|
2103
2108
|
function BackdatePosition(date, observerBody, targetBody, aberration) {
|
|
2109
|
+
VerifyBoolean(aberration);
|
|
2104
2110
|
const time = MakeTime(date);
|
|
2105
2111
|
if (UserDefinedStar(targetBody)) {
|
|
2106
2112
|
const tvec = HelioVector(targetBody, time);
|
|
2107
|
-
{
|
|
2113
|
+
if (aberration) {
|
|
2108
2114
|
const ostate = HelioState(observerBody, time);
|
|
2109
2115
|
const rvec = new Vector(tvec.x - ostate.x, tvec.y - ostate.y, tvec.z - ostate.z, time);
|
|
2110
2116
|
const s = C_AUDAY / rvec.Length();
|
|
2111
2117
|
return new Vector(rvec.x + ostate.vx / s, rvec.y + ostate.vy / s, rvec.z + ostate.vz / s, time);
|
|
2112
2118
|
}
|
|
2119
|
+
const ovec = HelioVector(observerBody, time);
|
|
2120
|
+
return new Vector(tvec.x - ovec.x, tvec.y - ovec.y, tvec.z - ovec.z, time);
|
|
2113
2121
|
}
|
|
2114
2122
|
let observerPos;
|
|
2115
|
-
{
|
|
2123
|
+
if (aberration) {
|
|
2116
2124
|
observerPos = new Vector(0, 0, 0, time);
|
|
2125
|
+
} else {
|
|
2126
|
+
observerPos = HelioVector(observerBody, time);
|
|
2117
2127
|
}
|
|
2118
2128
|
const bpos = new BodyPosition(observerBody, targetBody, aberration, observerPos);
|
|
2119
2129
|
return CorrectLightTravel((t) => bpos.Position(t), time);
|
|
2120
2130
|
}
|
|
2121
2131
|
function GeoVector(body, date, aberration) {
|
|
2132
|
+
VerifyBoolean(aberration);
|
|
2122
2133
|
const time = MakeTime(date);
|
|
2123
2134
|
switch (body) {
|
|
2124
2135
|
case Body.Earth:
|
|
@@ -2264,13 +2275,6 @@ function Search(f, t1, t2, options) {
|
|
|
2264
2275
|
return null;
|
|
2265
2276
|
}
|
|
2266
2277
|
}
|
|
2267
|
-
function EclipticLongitude(body, date) {
|
|
2268
|
-
if (body === Body.Sun)
|
|
2269
|
-
throw "Cannot calculate heliocentric longitude of the Sun.";
|
|
2270
|
-
const hv = HelioVector(body, date);
|
|
2271
|
-
const eclip = Ecliptic(hv);
|
|
2272
|
-
return eclip.elon;
|
|
2273
|
-
}
|
|
2274
2278
|
var AtmosphereInfo = class {
|
|
2275
2279
|
constructor(pressure, temperature, density) {
|
|
2276
2280
|
this.pressure = pressure;
|
|
@@ -2539,12 +2543,6 @@ function normalize360(degrees) {
|
|
|
2539
2543
|
if (r === 0) return 0;
|
|
2540
2544
|
return r < 0 ? r + 360 : r;
|
|
2541
2545
|
}
|
|
2542
|
-
function degToRad(degrees) {
|
|
2543
|
-
return degrees * (Math.PI / 180);
|
|
2544
|
-
}
|
|
2545
|
-
function radToDeg(radians) {
|
|
2546
|
-
return radians * (180 / Math.PI);
|
|
2547
|
-
}
|
|
2548
2546
|
|
|
2549
2547
|
// src/astronomy/moon.ts
|
|
2550
2548
|
function getSiderealMoonLongitude(date, ayanamsaType) {
|
|
@@ -4022,16 +4020,14 @@ var GRAHA_ABBR = {
|
|
|
4022
4020
|
Rahu: "Ra",
|
|
4023
4021
|
Ketu: "Ke"
|
|
4024
4022
|
};
|
|
4025
|
-
function meanObliquity(T) {
|
|
4026
|
-
return 23.439291111 - 0.013004167 * T - 164e-9 * T * T + 504e-9 * T * T * T;
|
|
4027
|
-
}
|
|
4028
4023
|
function getTropicalPlanetLongitude(body, date) {
|
|
4029
|
-
|
|
4024
|
+
const vec = GeoVector(body, MakeTime(date), true);
|
|
4025
|
+
return Ecliptic(vec).elon;
|
|
4030
4026
|
}
|
|
4031
4027
|
function isRetrograde(body, date) {
|
|
4032
4028
|
const dt = 36e5;
|
|
4033
|
-
const lon0 =
|
|
4034
|
-
const lon1 =
|
|
4029
|
+
const lon0 = Ecliptic(GeoVector(body, MakeTime(new Date(date.getTime() - dt)), false)).elon;
|
|
4030
|
+
const lon1 = Ecliptic(GeoVector(body, MakeTime(new Date(date.getTime() + dt)), false)).elon;
|
|
4035
4031
|
let delta = lon1 - lon0;
|
|
4036
4032
|
if (delta > 180) delta -= 360;
|
|
4037
4033
|
if (delta < -180) delta += 360;
|
|
@@ -4057,9 +4053,7 @@ function buildGrahaPosition(planet, siderealLon, isRetro, nakshatraNameFn, rashi
|
|
|
4057
4053
|
rashi: { index: rashiIndex, name: rashiNameFn(rashiIndex) },
|
|
4058
4054
|
degreeInRashi,
|
|
4059
4055
|
nakshatra: computeNakshatraFromLongitude(siderealLon, nakshatraNameFn(nakIdx)),
|
|
4060
|
-
isRetrograde: isRetro
|
|
4061
|
-
house: 0
|
|
4062
|
-
// assigned later in computeKundli
|
|
4056
|
+
isRetrograde: isRetro
|
|
4063
4057
|
};
|
|
4064
4058
|
}
|
|
4065
4059
|
var identity = (idx) => String(idx);
|
|
@@ -4095,41 +4089,6 @@ function computePlanetaryPositions(date, ayanamsaType, nakshatraName = identity,
|
|
|
4095
4089
|
};
|
|
4096
4090
|
}
|
|
4097
4091
|
|
|
4098
|
-
// src/jyotish/lagna.ts
|
|
4099
|
-
function computeLagnaLongitude(date, latitude, longitude, ayanamsaType) {
|
|
4100
|
-
const gastHours = SiderealTime(MakeTime(date));
|
|
4101
|
-
const last_deg = normalize360(gastHours * 15 + longitude);
|
|
4102
|
-
const T = (dateToJulianDay(date) - 2451545) / 36525;
|
|
4103
|
-
const eps_deg = meanObliquity(T);
|
|
4104
|
-
const ramc = degToRad(last_deg);
|
|
4105
|
-
const eps = degToRad(eps_deg);
|
|
4106
|
-
const phi = degToRad(latitude);
|
|
4107
|
-
const y = -Math.cos(ramc);
|
|
4108
|
-
const x = Math.sin(ramc) * Math.cos(eps) + Math.tan(phi) * Math.sin(eps);
|
|
4109
|
-
let tropicalAsc = normalize360(radToDeg(Math.atan2(y, x)));
|
|
4110
|
-
const mcRaw = radToDeg(Math.atan2(Math.tan(ramc), Math.cos(eps)));
|
|
4111
|
-
const mc = normalize360(
|
|
4112
|
-
last_deg < 180 ? normalize360(mcRaw) : normalize360(mcRaw + 180)
|
|
4113
|
-
);
|
|
4114
|
-
const diff = normalize360(tropicalAsc - mc);
|
|
4115
|
-
if (diff < 90 || diff > 270) {
|
|
4116
|
-
tropicalAsc = normalize360(tropicalAsc + 180);
|
|
4117
|
-
}
|
|
4118
|
-
const ayanamsa = computeAyanamsa(date, ayanamsaType);
|
|
4119
|
-
return normalize360(tropicalAsc - ayanamsa);
|
|
4120
|
-
}
|
|
4121
|
-
function navamsaRashi(siderealLongitude) {
|
|
4122
|
-
const rashiIdx = Math.floor(siderealLongitude / 30);
|
|
4123
|
-
const degInRashi = siderealLongitude - rashiIdx * 30;
|
|
4124
|
-
const navamsaIndex = Math.floor(degInRashi / (30 / 9));
|
|
4125
|
-
const NAVAMSA_STARTS = [0, 9, 6, 3, 0, 9, 6, 3, 0, 9, 6, 3];
|
|
4126
|
-
return (NAVAMSA_STARTS[rashiIdx] + navamsaIndex) % 12;
|
|
4127
|
-
}
|
|
4128
|
-
function rashiFromLongitude(lon, nameFn) {
|
|
4129
|
-
const index = Math.floor(lon / 30);
|
|
4130
|
-
return { index, name: nameFn(index) };
|
|
4131
|
-
}
|
|
4132
|
-
|
|
4133
4092
|
// src/jyotish/dasha.ts
|
|
4134
4093
|
var DASHA_YEARS = {
|
|
4135
4094
|
Ketu: 7,
|
|
@@ -4230,74 +4189,6 @@ function buildAntarDashas(mahaLord, mahaStart, mahaDurationMs) {
|
|
|
4230
4189
|
}
|
|
4231
4190
|
return antarDashas;
|
|
4232
4191
|
}
|
|
4233
|
-
|
|
4234
|
-
// src/jyotish/kundli.ts
|
|
4235
|
-
function computeKundli(birthDateUtc, location, options) {
|
|
4236
|
-
validateDate(birthDateUtc);
|
|
4237
|
-
validateLocation(location);
|
|
4238
|
-
const ayanamsa = options?.ayanamsa ?? "lahiri";
|
|
4239
|
-
const lang = options?.language ?? "en";
|
|
4240
|
-
const doDasha = options?.computeDasha !== false;
|
|
4241
|
-
const rashiName = (idx) => resolveMasaName(idx, lang);
|
|
4242
|
-
const nakshatraName = (idx) => resolveNakshatraName(idx, lang);
|
|
4243
|
-
const birthPanchang = getInstantPanchang(birthDateUtc, location, {
|
|
4244
|
-
ayanamsa,
|
|
4245
|
-
language: lang,
|
|
4246
|
-
computeEndTimes: options?.computeEndTimes ?? false,
|
|
4247
|
-
precision: options?.precision
|
|
4248
|
-
});
|
|
4249
|
-
const grahas = computePlanetaryPositions(birthDateUtc, ayanamsa, nakshatraName, rashiName);
|
|
4250
|
-
const lagnaLon = computeLagnaLongitude(
|
|
4251
|
-
birthDateUtc,
|
|
4252
|
-
location.latitude,
|
|
4253
|
-
location.longitude,
|
|
4254
|
-
ayanamsa
|
|
4255
|
-
);
|
|
4256
|
-
const lagna = rashiFromLongitude(lagnaLon, rashiName);
|
|
4257
|
-
const lagnaRashiIdx = lagna.index;
|
|
4258
|
-
const houses = Array.from({ length: 12 }, (_, i) => {
|
|
4259
|
-
const houseRashiIdx = (lagnaRashiIdx + i) % 12;
|
|
4260
|
-
return {
|
|
4261
|
-
number: i + 1,
|
|
4262
|
-
rashi: { index: houseRashiIdx, name: rashiName(houseRashiIdx) },
|
|
4263
|
-
planets: []
|
|
4264
|
-
};
|
|
4265
|
-
});
|
|
4266
|
-
const grahaList = Object.values(grahas);
|
|
4267
|
-
for (const graha of grahaList) {
|
|
4268
|
-
const houseNumber = (graha.rashi.index - lagnaRashiIdx + 12) % 12 + 1;
|
|
4269
|
-
graha.house = houseNumber;
|
|
4270
|
-
houses[houseNumber - 1].planets.push(GRAHA_ABBR[graha.planet]);
|
|
4271
|
-
}
|
|
4272
|
-
const navamsa = buildNavamsaChart(grahas, lagnaLon, rashiName);
|
|
4273
|
-
const dasha = doDasha ? computeVimshottariDasha(birthDateUtc, birthPanchang.siderealMoon) : { currentMahaDashaLord: "Sun", currentIndex: 0, mahaDashas: [] };
|
|
4274
|
-
return {
|
|
4275
|
-
lagnaLongitude: lagnaLon,
|
|
4276
|
-
lagna,
|
|
4277
|
-
houses,
|
|
4278
|
-
grahas,
|
|
4279
|
-
navamsa,
|
|
4280
|
-
birthPanchang,
|
|
4281
|
-
dasha
|
|
4282
|
-
};
|
|
4283
|
-
}
|
|
4284
|
-
function buildNavamsaChart(grahas, lagnaLon, rashiName) {
|
|
4285
|
-
const grahaList = Object.values(grahas);
|
|
4286
|
-
const positions = grahaList.map((g) => ({
|
|
4287
|
-
planet: g.planet,
|
|
4288
|
-
rashi: {
|
|
4289
|
-
index: navamsaRashi(g.siderealLongitude),
|
|
4290
|
-
name: rashiName(navamsaRashi(g.siderealLongitude))
|
|
4291
|
-
}
|
|
4292
|
-
}));
|
|
4293
|
-
return {
|
|
4294
|
-
positions,
|
|
4295
|
-
lagna: {
|
|
4296
|
-
index: navamsaRashi(lagnaLon),
|
|
4297
|
-
name: rashiName(navamsaRashi(lagnaLon))
|
|
4298
|
-
}
|
|
4299
|
-
};
|
|
4300
|
-
}
|
|
4301
4192
|
/*! Bundled license information:
|
|
4302
4193
|
|
|
4303
4194
|
astronomy-engine/esm/astronomy.js:
|
|
@@ -4336,4 +4227,4 @@ astronomy-engine/esm/astronomy.js:
|
|
|
4336
4227
|
*)
|
|
4337
4228
|
*/
|
|
4338
4229
|
|
|
4339
|
-
export { GRAHA_ABBR, PanchangError, computeAbhijitMuhurta, computeBrahmaMuhurta, computeGowriPanchangam, computeGulikaKalam,
|
|
4230
|
+
export { GRAHA_ABBR, PanchangError, computeAbhijitMuhurta, computeBrahmaMuhurta, computeGowriPanchangam, computeGulikaKalam, computePlanetaryPositions, computeRahuKalam, computeVimshottariDasha, computeYamaganda, computeAyanamsa as getAyanamsa, getDailyPanchang, getInstantPanchang, getMoonrise, getMoonset, getSiderealMoonLongitude, getSiderealSunLongitude, computeSunrise as getSunrise, computeSunset as getSunset };
|
package/package.json
CHANGED