private void PopulateOptionsInit(Division dtype) { DivisionPosition dp = h.getPosition(mBody).toDivisionPosition(this.dtypeRasi); Longitude foundLon = new Longitude(0); bool bForward = true; ut_lower = cs.TransitSearch(mBody, h.info.tob, false, new Longitude(dp.cusp_lower), foundLon, ref bForward); ut_higher = cs.TransitSearch(mBody, h.info.tob, true, new Longitude(dp.cusp_higher), foundLon, ref bForward); double ut_span = (ut_higher - ut_lower) / (double)Basics.numPartsInDivision(dtype) * 5.0; double ut_curr = h.baseUT; ut_lower = ut_curr - (ut_span / 2.0); ut_higher = ut_curr + (ut_span / 2.0); //double ut_extra = (ut_higher-ut_lower)*(1.0/3.0); //ut_lower -= ut_extra; //ut_higher += ut_extra; //ut_lower = h.baseUT - 1.0/24.0; //ut_higher = h.baseUT + 1.0/24.0; this.opts = new UserOptions(this.utToMoment(ut_lower), this.utToMoment(ut_higher), dtype); }
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); }
private void PopulateCache() { momentCusps = new double[opts.Divisions.Length][]; zhCusps = new ZodiacHouse.Name[opts.Divisions.Length][]; for (int i = 0; i < opts.Divisions.Length; i++) { Division dtype = opts.Divisions[i]; ArrayList al = new ArrayList(); ArrayList zal = new ArrayList(); //Console.WriteLine ("Calculating cusps for {0} between {1} and {2}", // dtype, this.utToMoment(ut_lower), this.utToMoment(ut_higher)); double ut_curr = ut_lower - (1.0 / (24.0 * 60.0)); sweph.obtainLock(h); BodyPosition bp = Basics.CalculateSingleBodyPosition(ut_curr, sweph.BodyNameToSweph(mBody), mBody, BodyType.Name.Graha, h); sweph.releaseLock(h); //BodyPosition bp = (BodyPosition)h.getPosition(mBody).Clone(); //DivisionPosition dp = bp.toDivisionPosition(this.dtypeRasi); DivisionPosition dp = bp.toDivisionPosition(dtype); //Console.WriteLine ("Longitude at {0} is {1} as is in varga rasi {2}", // this.utToMoment(ut_curr), bp.longitude, dp.zodiac_house.value); //bp.longitude = new Longitude(dp.cusp_lower - 0.2); //dp = bp.toDivisionPosition(dtype); while (true) { Moment m = this.utToMoment(ut_curr); Longitude foundLon = new Longitude(0); bool bForward = true; //Console.WriteLine (" Starting search at {0}", this.utToMoment(ut_curr)); ut_curr = cs.TransitSearch(mBody, this.utToMoment(ut_curr), true, new Longitude(dp.cusp_higher), foundLon, ref bForward); bp.longitude = new Longitude(dp.cusp_higher + 0.1); dp = bp.toDivisionPosition(dtype); if (ut_curr >= ut_lower && ut_curr <= ut_higher + (1.0 / (24.0 * 60.0 * 60.0)) * 5.0) { // Console.WriteLine ("{0}: {1} at {2}", // dtype, foundLon, this.utToMoment(ut_curr)); al.Add(ut_curr); zal.Add(dp.zodiac_house.value); } else if (ut_curr > ut_higher) { // Console.WriteLine ("- {0}: {1} at {2}", // dtype, foundLon, this.utToMoment(ut_curr)); break; } ut_curr += ((1.0 / (24.0 * 60.0 * 60.0)) * 5.0); } momentCusps[i] = (double[])al.ToArray(typeof(double)); zhCusps[i] = (ZodiacHouse.Name[])zal.ToArray(typeof(ZodiacHouse.Name)); } //for (int i=0; i<opts.Divisions.Length; i++) //{ // for (int j=0; j<momentCusps[i].Length; j++) // { // Console.WriteLine ("Cusp for {0} at {1}", opts.Divisions[i], momentCusps[i][j]); // } //} }