/* * * Routines for calculation begining and ending times of given Tithi * * Main function is GetTithiTimes * */ public static double GetTithiTimes(GCEarthData ed, GregorianDateTime vc, out double titBeg, out double titEnd, double sunRise) { GregorianDateTime d1, d2; vc.shour = sunRise; GCTithi.GetPrevTithiStart(ed, vc, out d1); GCTithi.GetNextTithiStart(ed, vc, out d2); titBeg = d1.shour + d1.GetJulian() - vc.GetJulian(); titEnd = d2.shour + d2.GetJulian() - vc.GetJulian(); return(titEnd - titBeg); }
private void CalculatePlanetRasi(int bodyId, GCLocation loc, GregorianDateTime vcEnd, GregorianDateTime vcAdd, GCConfigRatedEvents rec) { int nData; double JD, JDE; JD = vcAdd.GetJulian() - 0.5 - loc.OffsetUtcHours / 24.0; JDE = vcEnd.GetJulian() + 0.5 - loc.OffsetUtcHours / 24.0; nData = GCMath.IntFloor(GCMath.putIn360(GCVSOPAstronomy.GetPlanetLongitude(bodyId, JD) - GCAyanamsha.GetAyanamsa(JD)) / 30.0); // initial rasi at the start date 00:00 AddRating(JD, loc, rec.rateGrahaRasi[bodyId, nData], rec.rateGrahaRasi[bodyId, Prev(nData, 12)]); while ((JD = FindNextRasiChange(JD, JDE, bodyId, out nData)) < JDE) { AddRating(JD, loc, rec.rateGrahaRasi[bodyId, nData], rec.rateGrahaRasi[bodyId, Prev(nData, 12)]); JD += 1.0; } }
private void CalculatePlanetHouse(int bodyId, GCLocation loc, GregorianDateTime vcEnd, GregorianDateTime vcAdd, GCConfigRatedEvents rec) { int nData; double JD, JDE; GCEarthData earth = loc.GetEarthData(); JD = vcAdd.GetJulian() - 0.5 - loc.OffsetUtcHours / 24.0; JDE = vcEnd.GetJulian() + 0.5 - loc.OffsetUtcHours / 24.0; // initial rasi at the start date 00:00 nData = GCMath.IntFloor(GetPlanetHouse(GCVSOPAstronomy.GetPlanetLongitude(bodyId, JD), JD, earth)); AddRating(JD, loc, rec.rateGrahaHouse[bodyId, nData], rec.rateGrahaHouse[bodyId, Prev(nData, 12)]); while ((JD = FindNextHouseChange(JD, JDE, bodyId, earth, out nData)) < JDE) { AddRating(JD, loc, rec.rateGrahaHouse[bodyId, nData], rec.rateGrahaHouse[bodyId, Prev(nData, 12)]); JD += 1.0 / 24.0; } }
/*********************************************************************/ /* Finds next time when rasi is changed */ /* */ /* startDate - starting date and time, timezone member must be valid */ /* zodiac [out] - found zodiac sign into which is changed */ /* */ /*********************************************************************/ public static GregorianDateTime GetNextSankranti(GregorianDateTime startDate, GCEarthData earth, out int zodiac) { GregorianDateTime d = new GregorianDateTime(); double step = 1.0; int count = 0; double ld, prev; int prev_rasi, new_rasi; GregorianDateTime prevday; d.Set(startDate); //d.ChangeTimeZone(0.0); //d.shour = 0.0; zodiac = 0; prev = GCMath.putIn360(GCCoreAstronomy.GetSunLongitude(d, earth) - GCAyanamsha.GetAyanamsa(d.GetJulian())); prev_rasi = GCMath.IntFloor(prev / 30.0); while (count < 20) { prevday = new GregorianDateTime(); prevday.Set(d); d.shour += step; if (d.shour > 1.0) { d.shour -= 1.0; d.NextDay(); } ld = GCMath.putIn360(GCCoreAstronomy.GetSunLongitude(d, earth) - GCAyanamsha.GetAyanamsa(d.GetJulian())); new_rasi = GCMath.IntFloor(ld / 30.0); if (prev_rasi != new_rasi) { zodiac = new_rasi; //v uplynulom dni je sankranti step *= 0.5; d.Set(prevday); count++; continue; } } return(d); }
/////////////////////////////////////////////////////////////////////// // GET PREVIOUS CONJUNCTION OF THE SUN AND MOON // // THIS IS HELP FUNCTION FOR GetPrevConjunction(VCTIME test_date, // VCTIME &found, bool this_day, EARTHDATA earth) // // looking for previous sun-moon conjunction // it starts from input day from 12:00 AM (noon) UTC // so output can be the same day // if output is the same day, then conjunction occurs between 00:00 AM and noon of this day // // date - input / output // earth - input // return value - sun longitude in degs // // error is when return value is greater than 999.0 deg public static double GetPrevConjunction(ref GregorianDateTime date, GCEarthData earth) { int bCont = 32; double prevSun = 0.0, prevMoon = 0.0, prevDiff = 0.0; double nowSun = 0.0, nowMoon = 0.0, nowDiff = 0.0; // SUNDATA sun; double jd, longitudeMoon; GregorianDateTime d = new GregorianDateTime(); d.Set(date); d.shour = 0.5; d.TimezoneHours = 0.0; jd = d.GetJulian();//GetJulianDay(d.year, d.month, d.day); // set initial data for input day // NOTE: for grenwich //SunPosition(d, earth, sun); longitudeMoon = GCCoreAstronomy.GetMoonLongitude(d, earth); prevSun = GCSunData.GetSunLongitude(d); prevMoon = longitudeMoon; prevDiff = GCMath.putIn180(prevSun - prevMoon); do { // shift to day before d.PreviousDay(); jd -= 1.0; // calculation //SunPosition(d, earth, sun); longitudeMoon = GCCoreAstronomy.GetMoonLongitude(d, earth); nowSun = GCSunData.GetSunLongitude(d); nowMoon = longitudeMoon; nowDiff = GCMath.putIn180(nowSun - nowMoon); // if difference of previous has another sign than now calculated // then it is the case that moon was faster than sun and he //printf(" prevsun=%f\nprevmoon=%f\nnowsun=%f\nnowmoon=%f\n", prevSun, prevMoon, nowSun, nowMoon); if (IsConjunction(nowMoon, nowSun, prevSun, prevMoon)) { // now it calculates actual time and zodiac of conjunction double x; if (prevDiff == nowDiff) { return(0); } x = Math.Abs(nowDiff) / Math.Abs(prevDiff - nowDiff); if (x < 0.5) { d.shour = x + 0.5; } else { d.NextDay(); d.shour = x - 0.5; } date.Set(d); double other = GCSunData.GetSunLongitude(d); // double other2 = nowSun + (prevSun - nowSun)*x; GCMath.putIn360(prevSun); GCMath.putIn360(nowSun); if (Math.Abs(prevSun - nowSun) > 10.0) { return(GCMath.putIn180(nowSun) + (GCMath.putIn180(prevSun) - GCMath.putIn180(nowSun)) * x); } else { return(nowSun + (prevSun - nowSun) * x); } // return other2; } prevSun = nowSun; prevMoon = nowMoon; prevDiff = nowDiff; bCont--; }while (bCont >= 0); return(1000.0); }