-
Notifications
You must be signed in to change notification settings - Fork 10
Calculate Tithi and Paksha
trenholm edited this page Nov 22, 2011
·
2 revisions
Lunar calendars are based on the moon's rotation around the Earth. A tithi is the time taken for the longitudinal angle between the moon and the sun to increase by 12 degrees. A lunar month consists of 30 tithis, whose start time and duration vary.
The formula for caluclating the tithi (and the paksha) requires that we know the longitudinal angle between the sun and the moon.
(i.e. the angle 'A' in this diagram)
$sunLon = sun.getLongitude();
$moonLon = moon.getLongitude();
public function getDiff($sunLon, $moonLon) {
$diff = moonLon - sunLon;
if (diff < 0)
diff = diff + 360;
return diff;
}
public function calculateTithi($diff) {
// Determine Tithi (lunar day)
$ti = $diff / 12;
// Classical calculations involve adding a one here,
// but it is omitted because of array position counting
$tithiNames = array(
"1. Pratipat",
"2. Dvitiya",
"3. Tritiya",
"4. Chaturthi",
"5. Panchami",
"6. Shashti",
"7. Saptami",
"8. Ashtami",
"9. Navami",
"10. Dashami",
"11. Ekadashi",
"12. Dvadashi",
"13. Trayodashi",
"14. Chaturdashi",
"15. Purnima",
"1. Pratipat",
"2. Dvitiya",
"3. Tritiya",
"4. Chaturthi",
"5. Panchami",
"6. Shashti",
"7. Saptami",
"8. Ashtami",
"9. Navami",
"10. Dashami",
"11. Ekadashi",
"12. Dvadashi",
"13. Trayodashi",
"14. Chaturdashi",
"15. Amavasya"
);
// Determine Paksha (phase of moon)
if ($ti < 15)
$paksha = "Shukla";
else if (15 <= $ti)
$paksha = "Krishna";
// Create an array of the resulting tithi and paksha
$result = array();
$result["tithi"] = $tithiNames[ti];
$result["paksha"] = $paksha;
return $result;
}
