public double TransitSearchDirect(Body.Name SearchBody, Moment StartDate, bool Forward, Longitude TransitPoint, Longitude FoundLon, ref bool bForward) { bool bDiscard = true; sweph.obtainLock(h); Transit t = new Transit(h, SearchBody); double ut_base = StartDate.toUniversalTime() - h.info.TimeZone.toDouble() / 24.0; Longitude lon_curr = t.GenericLongitude(ut_base, ref bDiscard); sweph.releaseLock(h); double diff = 0; diff = TransitPoint.sub(lon_curr).value; if (false == Forward) { diff -= 360.0; } double ut_diff_approx = diff / 360.0 * this.DirectSpeed(SearchBody); sweph.obtainLock(h); double found_ut = 0; if (SearchBody == Body.Name.Lagna) { found_ut = t.LinearSearchBinary(ut_base + ut_diff_approx - 3.0 / 24.0, ut_base + ut_diff_approx + 3.0 / 24.0, TransitPoint, new ReturnLon(t.GenericLongitude)); } else { found_ut = t.LinearSearch(ut_base + ut_diff_approx, TransitPoint, new ReturnLon(t.GenericLongitude)); } FoundLon.value = t.GenericLongitude(found_ut, ref bForward).value; bForward = true; sweph.releaseLock(h); return(found_ut); }
private void ComputeEntry(double ut, double[] geopos) { int year = 0, month = 0, day = 0; double sunset = 0, hour = 0; sweph.obtainLock(h); h.populateSunrisetCacheHelper(ut - 0.5, ref sunrise, ref sunset, ref ut_sr); sweph.releaseLock(h); sweph.swe_revjul(ut_sr, ref year, ref month, ref day, ref hour); Moment moment_sr = new Moment(year, month, day, hour); Moment moment_ut = new Moment(ut, h); HoraInfo infoCurr = new HoraInfo(moment_ut, h.info.lat, h.info.lon, h.info.tz); Horoscope hCurr = new Horoscope(infoCurr, h.options); ListViewItem li = null; PanchangaLocalMoments local = new PanchangaLocalMoments(); local.sunrise = hCurr.sunrise; local.sunset = sunset; local.sunrise_ut = ut_sr; sweph.swe_revjul(ut, ref year, ref month, ref day, ref hour); local.wday = (Basics.Weekday)sweph.swe_day_of_week(ut); local.kalas_ut = hCurr.getKalaCuspsUt(); if (this.opts.CalcSpecialKalas) { Body.Name bStart = Basics.weekdayRuler(hCurr.wday); if (hCurr.options.KalaType == HoroscopeOptions.EHoraType.Lmt) { bStart = Basics.weekdayRuler(hCurr.lmt_wday); } local.rahu_kala_index = this.rahu_kalas[(int)bStart]; local.gulika_kala_index = this.gulika_kalas[(int)bStart]; local.yama_kala_index = this.yama_kalas[(int)bStart]; } if (opts.CalcLagnaCusps) { li = new ListViewItem(); sweph.obtainLock(h); BodyPosition bp_lagna_sr = Basics.CalculateSingleBodyPosition(ut_sr, sweph.BodyNameToSweph(Body.Name.Lagna), Body.Name.Lagna, BodyType.Name.Lagna, h); DivisionPosition dp_lagna_sr = bp_lagna_sr.toDivisionPosition(new Division(Basics.DivisionType.Rasi)); local.lagna_zh = dp_lagna_sr.zodiac_house.value; Longitude bp_lagna_base = new Longitude(bp_lagna_sr.longitude.toZodiacHouseBase()); double ut_transit = ut_sr; for (int i = 1; i <= 12; i++) { Retrogression r = new Retrogression(h, Body.Name.Lagna); ut_transit = r.GetLagnaTransitForward(ut_transit, bp_lagna_base.add(i * 30.0)); PanchangaMomentInfo pmi = new PanchangaMomentInfo( ut_transit, (int)bp_lagna_sr.longitude.toZodiacHouse().add(i + 1).value); local.lagnas_ut.Add(pmi); } sweph.releaseLock(h); } if (opts.CalcTithiCusps) { Transit t = new Transit(h); sweph.obtainLock(h); Tithi tithi_start = t.LongitudeOfTithi(ut_sr).toTithi(); Tithi tithi_end = t.LongitudeOfTithi(ut_sr + 1.0).toTithi(); Tithi tithi_curr = tithi_start.add(1); local.tithi_index_start = globals.tithis_ut.Count - 1; local.tithi_index_end = globals.tithis_ut.Count - 1; while (tithi_start.value != tithi_end.value && tithi_curr.value != tithi_end.value) { tithi_curr = tithi_curr.add(2); double dLonToFind = ((double)(int)tithi_curr.value - 1) * (360.0 / 30.0); double ut_found = t.LinearSearchBinary(ut_sr, ut_sr + 1.0, new Longitude(dLonToFind), new ReturnLon(t.LongitudeOfTithiDir)); globals.tithis_ut.Add(new PanchangaMomentInfo(ut_found, (int)tithi_curr.value)); local.tithi_index_end++; } sweph.releaseLock(h); } if (opts.CalcKaranaCusps) { Transit t = new Transit(h); sweph.obtainLock(h); Karana karana_start = t.LongitudeOfTithi(ut_sr).toKarana(); Karana karana_end = t.LongitudeOfTithi(ut_sr + 1.0).toKarana(); Karana karana_curr = karana_start.add(1); local.karana_index_start = globals.karanas_ut.Count - 1; local.karana_index_end = globals.karanas_ut.Count - 1; while (karana_start.value != karana_end.value && karana_curr.value != karana_end.value) { karana_curr = karana_curr.add(2); double dLonToFind = ((double)(int)karana_curr.value - 1) * (360.0 / 60.0); double ut_found = t.LinearSearchBinary(ut_sr, ut_sr + 1.0, new Longitude(dLonToFind), new ReturnLon(t.LongitudeOfTithiDir)); globals.karanas_ut.Add(new PanchangaMomentInfo(ut_found, (int)karana_curr.value)); local.karana_index_end++; } sweph.releaseLock(h); } if (opts.CalcSMYogaCusps) { Transit t = new Transit(h); sweph.obtainLock(h); SunMoonYoga sm_start = t.LongitudeOfSunMoonYoga(ut_sr).toSunMoonYoga(); SunMoonYoga sm_end = t.LongitudeOfSunMoonYoga(ut_sr + 1.0).toSunMoonYoga(); SunMoonYoga sm_curr = sm_start.add(1); local.smyoga_index_start = globals.smyogas_ut.Count - 1; local.smyoga_index_end = globals.smyogas_ut.Count - 1; while (sm_start.value != sm_end.value && sm_curr.value != sm_end.value) { sm_curr = sm_curr.add(2); double dLonToFind = ((double)(int)sm_curr.value - 1) * (360.0 / 27); double ut_found = t.LinearSearchBinary(ut_sr, ut_sr + 1.0, new Longitude(dLonToFind), new ReturnLon(t.LongitudeOfSunMoonYogaDir)); globals.smyogas_ut.Add(new PanchangaMomentInfo(ut_found, (int)sm_curr.value)); local.smyoga_index_end++; } sweph.releaseLock(h); } if (opts.CalcNakCusps) { bool bDiscard = true; Transit t = new Transit(h, Body.Name.Moon); sweph.obtainLock(h); Nakshatra nak_start = t.GenericLongitude(ut_sr, ref bDiscard).toNakshatra(); Nakshatra nak_end = t.GenericLongitude(ut_sr + 1.0, ref bDiscard).toNakshatra(); local.nakshatra_index_start = globals.nakshatras_ut.Count - 1; local.nakshatra_index_end = globals.nakshatras_ut.Count - 1; Nakshatra nak_curr = nak_start.add(1); while (nak_start.value != nak_end.value && nak_curr.value != nak_end.value) { nak_curr = nak_curr.add(2); double dLonToFind = ((double)((int)nak_curr.value - 1)) * (360.0 / 27.0); double ut_found = t.LinearSearchBinary(ut_sr, ut_sr + 1.0, new Longitude(dLonToFind), new ReturnLon(t.GenericLongitude)); globals.nakshatras_ut.Add(new PanchangaMomentInfo(ut_found, (int)nak_curr.value)); Console.WriteLine("Found nakshatra {0}", nak_curr.value); local.nakshatra_index_end++; } sweph.releaseLock(h); } if (opts.CalcHoraCusps) { local.horas_ut = hCurr.getHoraCuspsUt(); hCurr.calculateHora(ut_sr + 1.0 / 24.0, ref local.hora_base); } if (opts.CalcKalaCusps) { hCurr.calculateKala(ref local.kala_base); } this.locals.Add(local); this.DisplayEntry(local); }