Exemplo n.º 1
0
        /*********************************************************************/
        /*                                                                   */
        /* Calculation of tithi, paksa, naksatra, yoga for given             */
        /*    Gregorian date                                                 */
        /*                                                                   */
        /*                                                                   */
        /*********************************************************************/

        public int DayCalc(GregorianDateTime date, GCEarthData earth)
        {
            double d;

            // sun position on sunrise on that day
            sunRise = GCSunData.CalcSunrise(date, earth);
            sunSet  = GCSunData.CalcSunset(date, earth);

            // arunodaya is 96 min before sunrise
            //  sunrise_deg is from range 0-360 so 96min=24deg
            sunArunodaya.TotalDays = sunRise.TotalDays - 96 / 1440.0;
            sunArunodaya.longitude = sunRise.longitude - (24.0 / 365.25);
            // noon
            sunNoon.TotalDays = (sunSet.TotalDays + sunRise.TotalDays) / 2;
            sunNoon.longitude = (sunRise.longitude + sunSet.longitude) / 2;

            date.shour = sunRise.TotalDays;

            // date.shour is [0..1] time of sunrise in local timezone time
            this.JulianDay = date.GetJulianDetailed();

            // moon position at sunrise on that day
            sunRise.longitudeMoon = GCCoreAstronomy.GetMoonLongitude(date, earth);

            this.Ayanamsa         = GCAyanamsha.GetAyanamsa(this.JulianDay);
            sunArunodaya.Ayanamsa = this.Ayanamsa;
            sunRise.Ayanamsa      = this.Ayanamsa;
            sunNoon.Ayanamsa      = this.Ayanamsa;
            sunSet.Ayanamsa       = this.Ayanamsa;

            // masa
            this.Masa = -1;

            date.shour           = sunSet.TotalDays;
            sunSet.longitudeMoon = GCCoreAstronomy.GetMoonLongitude(date, earth);


            date.shour = sunArunodaya.TotalDays;
            sunArunodaya.longitudeMoon = GCCoreAstronomy.GetMoonLongitude(date, earth);


            return(1);
        }
Exemplo n.º 2
0
        public int GetNextAscendentStart(GregorianDateTime startDate, out GregorianDateTime nextDate)
        {
            int               countOfElements = 12;
            double            phi = 360.0 / countOfElements;
            double            l1, l2;
            double            jday = startDate.GetJulianDetailed();
            double            xj;
            GregorianDateTime d = new GregorianDateTime(startDate);

            // we are calculating in UTC timezone
            d.shour        -= startDate.TimezoneHours / 24.0;
            d.TimezoneHours = 0.0;
            GregorianDateTime xd        = new GregorianDateTime();
            double            scan_step = 1.0 / 48.0;
            int prev_tit = 0;
            int new_tit  = -1;

            l1 = GetAscendantDegrees(jday);

            prev_tit = Convert.ToInt32(Math.Floor(l1 / phi));
            //Debugger.Log(0, "", "=== FROM " + startDate.LongTimeString() + " ===\n");
            //Debugger.Log(0, "", string.Format("{0:00}: {1} {2}     {3} {4} \n", 99, l1, prev_tit, jday, d.LongTimeString()));
            int counter = 0;

            while (counter < 20)
            {
                xj = jday;
                xd.Set(d);

                jday    += scan_step;
                d.shour += scan_step;
                if (d.shour > 1.0)
                {
                    d.shour -= 1.0;
                    d.NextDay();
                }

                l2      = GetAscendantDegrees(jday);
                new_tit = Convert.ToInt32(Math.Floor(l2 / phi));
                //Debugger.Log(0, "", string.Format("{0:00}: {1} {2}     {3} {4} \n", counter, l1, prev_tit, jday, d.LongTimeString()));

                if (prev_tit != new_tit)
                {
                    jday = xj;
                    d.Set(xd);
                    scan_step *= 0.5;
                    counter++;
                    //Debugger.Log(0, "", string.Format("   Going back to {0}\n", d.LongTimeString()));
                    continue;
                }
                else
                {
                    l1 = l2;
                }
            }
            // date D was calculated in timezone UTC+0h, therefore
            // we have to convert it into timezone of input datetime
            nextDate               = new GregorianDateTime(d);
            nextDate.shour        += startDate.TimezoneHours / 24.0;
            nextDate.TimezoneHours = startDate.TimezoneHours;
            nextDate.NormalizeValues();

            return(new_tit);
        }