Ejemplo n.º 1
0
        /// <summary>
        /// this will move date to the nearest conjunction
        /// whether it is in future or in the past
        /// </summary>
        /// <returns></returns>
        protected GPGregorianTime movePosition()
        {
            double position = 0;
            double diff;
            double seconds     = 0.5 / 86400.0;
            double prevSeconds = -1;

            for (int i = 0; i < 10; i++)
            {
                position = calculatePosition() / 360;
                if (Math.Abs(pJulianDate - prevSeconds) < seconds)
                {
                    break;
                }

                prevSeconds = pJulianDate;

                diff         = position * 30;
                pJulianDate -= diff;
                pStartDate.addDayHours(diff);
            }

            GPGregorianTime nt = new GPGregorianTime(pStartDate.getLocation());

            nt.setJulianGreenwichTime(new GPJulianTime(GPAstroEngine.ConvertDynamicToUniversal(pJulianDate), 0.0));
            return(nt);
        }
Ejemplo n.º 2
0
        public GPGregorianTime movePosition(int dir)
        {
            double unitLength = getUnitAverageLength();
            int    unitCount  = getUnitCount();

            double lowerLimit = 0.5;
            double upperLimit = unitCount - 0.5;
            double position   = 0;
            bool   over       = false;
            bool   under      = false;
            double nextTithi  = getCurrentPosition() + dir;
            double diff;
            double seconds     = 0.5 / 86400.0;
            double prevSeconds = -1;

            if (dir > 0)
            {
                over  = (nextTithi > upperLimit);
                under = (currentPosition < lowerLimit);
            }
            else
            {
                over  = (currentPosition > upperLimit);
                under = (nextTithi < lowerLimit);
            }
            for (int i = 0; i < 10; i++)
            {
                position = calculatePosition();
                //seconds = Convert.ToInt32((pJulianDate - Math.Floor(pJulianDate)) * 86400);
                if (Math.Abs(pJulianDate - prevSeconds) < seconds)
                {
                    break;
                }
                if (over && position < lowerLimit)
                {
                    position += unitCount;
                }
                else if (under && position > upperLimit)
                {
                    position -= unitCount;
                }

                prevSeconds = pJulianDate;

                diff         = (nextTithi - position) * unitLength;
                pJulianDate += diff;
                pStartDate.addDayHours(diff);
            }

            currentPosition = Convert.ToInt32(nextTithi) % unitCount;

            GPGregorianTime nt = new GPGregorianTime(pStartDate.getLocation());

            nt.setJulianGreenwichTime(new GPJulianTime(GPAstroEngine.ConvertDynamicToUniversal(pJulianDate), 0.0));
            return(nt);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// This can be used only after calculating sunrise and sunset time
 /// using functions calculateRise and calculateSet
 /// </summary>
 /// <param name="vct"></param>
 /// <param name="earth"></param>
 private void updateNoonTimes(GPGregorianTime vct, GPLocationProvider earth)
 {
     noon = new GPGregorianTime(vct);
     if (sunPosMethod == SUNPOSMETHOD_CALCULATOR)
     {
         noon.setDayHours(SetDegTime((sunset_deg + sunrise_deg) / 2 + earth.getTimeZoneOffsetHours() * 15.0));
     }
     else
     {
         noon.setJulianGreenwichTime(GPAstroEngine.ConvertDynamicToUniversal(julianDayNoon));
     }
 }
Ejemplo n.º 4
0
        public void updateSunriseTimes(GPGregorianTime vct, GPLocationProvider earth)
        {
            arunodaya_deg      = sunrise_deg - 24.0;
            longitude_arun_deg = eclipticalLongitude - 24.0 / 365.25;
            arunodaya          = new GPGregorianTime(vct);
            rise = new GPGregorianTime(vct);

            if (sunPosMethod == SUNPOSMETHOD_CALCULATOR)
            {
                // arunodaya is 96 min before sunrise
                //  sunrise_deg is from range 0-360 so 96min=24deg
                arunodaya.setDayHours(SetDegTime(arunodaya_deg + earth.getTimeZoneOffsetHours() * 15.0));
                rise.setDayHours(SetDegTime(sunrise_deg + earth.getTimeZoneOffsetHours() * 15.0));
            }
            else
            {
                arunodaya.setJulianGreenwichTime(GPAstroEngine.ConvertDynamicToUniversal(julianDayRise - 96 / 1440.0));
                rise.setJulianGreenwichTime(GPAstroEngine.ConvertDynamicToUniversal(julianDayRise));
            }
        }