Exemplo n.º 1
0
        //==================================================================================
        //
        //==================================================================================

        public static GregorianDateTime GetNextRise(GCEarthData e, GregorianDateTime vc, bool bRise)
        {
            double a, b;

            double[] h         = new double[3];
            double   hour      = 1 / 24.0;
            double   startHour = vc.shour;

            GregorianDateTime track = new GregorianDateTime();

            track.Set(vc);
            track.NormalizeValues();

            // inicializacia prvej hodnoty ELEVATION
            h[0]         = GCCoreAstronomy.GetMoonElevation(e, track);
            track.shour += hour;
            h[1]         = GCCoreAstronomy.GetMoonElevation(e, track);
            track.shour += hour;
            h[2]         = GCCoreAstronomy.GetMoonElevation(e, track);

            for (int c = 0; c < 24; c++)
            {
                if ((bRise ? (h[1] < 0.0 && h[2] > 0.0) : (h[1] > 0.0 && h[2] < 0.0)))
                {
                    a           = (h[2] - h[1]) / hour;
                    b           = h[2] - a * track.shour;
                    track.shour = -b / a;
                    track.NormalizeValues();
                    return(track);
                }

                h[0]         = h[1];
                h[1]         = h[2];
                track.shour += hour;
                h[2]         = GCCoreAstronomy.GetMoonElevation(e, track);
            }

            return(track);
        }
Exemplo n.º 2
0
        //==================================================================================
        //
        //==================================================================================

        public static void CalcMoonTimes(GCEarthData e, GregorianDateTime vc, double biasHours, out GCHourTime rise, out GCHourTime set)
        {
            double UT;
            int    i;
            double prev_elev;
            int    nType, nFound = 0;
            double a, ae, b, be, c = 0, ce = 0, elev;

            rise = new GCHourTime();
            set  = new GCHourTime();

            rise.SetValue(-1);
            set.SetValue(-1);

            // inicializacia prvej hodnoty ELEVATION
            vc.shour  = (-biasHours - 1.0) / 24.0;
            prev_elev = GCCoreAstronomy.GetMoonElevation(e, vc);

            // prechod cez vsetky hodiny
            for (UT = (-0.1 - biasHours); UT <= (24.1 - biasHours); UT += 1.0)
            {
                vc.shour = UT / 24.0;
                elev     = GCCoreAstronomy.GetMoonElevation(e, vc);

                if (prev_elev * elev <= 0.0)
                {
                    if (prev_elev <= 0.0)
                    {
                        nType = 0x1;
                    }
                    else
                    {
                        nType = 0x2;
                    }

                    a  = UT - 1.0;
                    ae = prev_elev;
                    b  = UT;
                    be = elev;
                    for (i = 0; i < 20; i++)
                    {
                        c        = (a + b) / 2.0;
                        vc.shour = c / 24.0;
                        ce       = GCCoreAstronomy.GetMoonElevation(e, vc);
                        if (ae * ce <= 0.0)
                        {
                            be = ce;
                            b  = c;
                        }
                        else
                        {
                            ae = ce;
                            a  = c;
                        }
                    }

                    if (nType == 1)
                    {
                        rise.SetDayTime((c + biasHours) / 24.0);
                    }
                    else
                    {
                        set.SetDayTime((c + biasHours) / 24.0);
                    }

                    nFound |= nType;

                    if (nFound == 0x3)
                    {
                        break;
                    }
                }

                prev_elev = elev;
            }
        }