UNPKG

@ishubhamx/panchangam-js

Version:

Enhanced Indian Panchangam (Hindu Calendar) library with comprehensive Vedic features including Muhurta calculations, planetary positions, Rashi placements, and auspicious/inauspicious time calculations

127 lines 4.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getNavamsaSign = getNavamsaSign; exports.getAllVargas = getAllVargas; exports.getNavamsaChart = getNavamsaChart; const constants_1 = require("../core/constants"); const houses_1 = require("./houses"); // --- Helper for creating full Chart --- function createVargaChart(ascendantLength, planets, calculationFn) { const ascRashi = calculationFn(ascendantLength); const dPlanets = {}; for (const [name, data] of Object.entries(planets)) { const sign = calculationFn(data.longitude); dPlanets[name] = { rashi: sign, rashiName: constants_1.rashiNames[sign] }; } // Assign planets to Houses (Whole Sign System for Vargas) // House 1 is the sign of the Ascendant. const ascDegree = (ascRashi * 30) + 15; const houses = (0, houses_1.getHouses)(ascDegree, 'whole_sign'); for (const [pName, pData] of Object.entries(dPlanets)) { const pRashi = pData.rashi; const house = houses.find((h) => h.rashi === pRashi); if (house) house.planets.push(pName); } return { ascendant: { rashi: ascRashi, rashiName: constants_1.rashiNames[ascRashi] }, planets: dPlanets, houses: houses }; } // --- D1 (Rashi) --- function getRashiSign(longitude) { return Math.floor(longitude / 30); } // --- D2 (Hora) --- // Parashara Hora: Odd Signs (0-15° = Sun/Leo, 15-30° = Moon/Cancer) // Even Signs (0-15° = Moon/Cancer, 15-30° = Sun/Leo) function getHoraSign(longitude) { const rashi = Math.floor(longitude / 30); const degrees = longitude % 30; const isOdd = (rashi % 2 === 0); // 0=Aries (Odd) if (isOdd) { return (degrees < 15) ? 4 : 3; // Leo(4), Cancer(3) } else { return (degrees < 15) ? 3 : 4; // Cancer(3), Leo(4) } } // --- D3 (Drekkana) --- // 0-10: Same Sign, 10-20: 5th, 20-30: 9th function getDrekkanaSign(longitude) { const rashi = Math.floor(longitude / 30); const degrees = longitude % 30; if (degrees < 10) return rashi; if (degrees < 20) return (rashi + 4) % 12; return (rashi + 8) % 12; } // --- D4 (Chaturthamsha) --- function getChaturthamshaSign(longitude) { const rashi = Math.floor(longitude / 30); const degrees = longitude % 30; const part = Math.floor(degrees / 7.5); return (rashi + (part * 3)) % 12; } // --- D7 (Saptamsa) --- function getSaptamsaSign(longitude) { const rashi = Math.floor(longitude / 30); const degrees = longitude % 30; const part = Math.floor(degrees / (30 / 7)); // 0 to 6 const isOdd = (rashi % 2 === 0); if (isOdd) { return (rashi + part) % 12; } else { const startSign = (rashi + 6) % 12; return (startSign + part) % 12; } } // --- D9 (Navamsa) --- function getNavamsaSign(longitude) { const navamsaSpan = 360 / 108; const index = Math.floor(longitude / navamsaSpan); return index % 12; } // --- D10 (Dasamsa) --- function getDasamsaSign(longitude) { const rashi = Math.floor(longitude / 30); const degrees = longitude % 30; const part = Math.floor(degrees / 3); const isOdd = (rashi % 2 === 0); if (isOdd) { return (rashi + part) % 12; } else { const startSign = (rashi + 8) % 12; return (startSign + part) % 12; } } // --- D12 (Dwadasamsa) --- function getDwadasamsaSign(longitude) { const rashi = Math.floor(longitude / 30); const degrees = longitude % 30; const part = Math.floor(degrees / 2.5); return (rashi + part) % 12; } // --- Main Export --- function getAllVargas(ascendantLength, planets) { return { d1: createVargaChart(ascendantLength, planets, getRashiSign), d2: createVargaChart(ascendantLength, planets, getHoraSign), d3: createVargaChart(ascendantLength, planets, getDrekkanaSign), d4: createVargaChart(ascendantLength, planets, getChaturthamshaSign), d7: createVargaChart(ascendantLength, planets, getSaptamsaSign), d9: createVargaChart(ascendantLength, planets, getNavamsaSign), d10: createVargaChart(ascendantLength, planets, getDasamsaSign), d12: createVargaChart(ascendantLength, planets, getDwadasamsaSign) }; } // Keep the old single export for backward compatibility or direct use if needed, // though getAllVargas covers it. function getNavamsaChart(ascendantLength, planets) { return createVargaChart(ascendantLength, planets, getNavamsaSign); } //# sourceMappingURL=vargas.js.map