예제 #1
0
 public void SetCoordinates(double longitude, double latitude)
 {
     Longitude = longitude;
     Latitude  = latitude;
     if (TimeZone != null)
     {
         TimeZone.OffsetMinutes = GCMath.IntFloor((longitude - 7.5) / 15) * 60;
     }
 }
예제 #2
0
        /*********************************************************************/
        /*                                                                   */
        /*   finds previous time when starts next tithi                      */
        /*                                                                   */
        /*   timezone is not changed                                         */
        /*                                                                   */
        /*   return value: index of tithi 0..29                              */
        /*                 or -1 if failed                                   */
        /*********************************************************************/

        public static int GetPrevTithiStart(GCEarthData ed, GregorianDateTime startDate, out GregorianDateTime nextDate)
        {
            double            phi = 12.0;
            double            l1, l2, longitudeSun, longitudeMoon;
            double            jday = startDate.GetJulianComplete();
            double            xj;
            GregorianDateTime d = new GregorianDateTime();

            d.Set(startDate);
            GregorianDateTime xd        = new GregorianDateTime();
            double            scan_step = 0.5;
            int prev_tit = 0;
            int new_tit  = -1;

            longitudeMoon = GCCoreAstronomy.GetMoonLongitude(d, ed);
            longitudeSun  = GCCoreAstronomy.GetSunLongitude(d, ed);
            l1            = GCMath.putIn360(longitudeMoon - longitudeSun - 180.0);
            prev_tit      = GCMath.IntFloor(l1 / phi);

            int counter = 0;

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

                jday    -= scan_step;
                d.shour -= scan_step;
                if (d.shour < 0.0)
                {
                    d.shour += 1.0;
                    d.PreviousDay();
                }

                longitudeSun  = GCCoreAstronomy.GetSunLongitude(d, ed);
                longitudeMoon = GCCoreAstronomy.GetMoonLongitude(d, ed);
                l2            = GCMath.putIn360(longitudeMoon - longitudeSun - 180.0);
                new_tit       = GCMath.IntFloor(l2 / phi);

                if (prev_tit != new_tit)
                {
                    jday = xj;
                    d.Set(xd);
                    scan_step *= 0.5;
                    counter++;
                    continue;
                }
                else
                {
                    l1 = l2;
                }
            }
            nextDate = d;
            //	nextDate.shour += startDate.tzone / 24.0;
            //	nextDate.NormalizeValues();
            return(new_tit);
        }
예제 #3
0
        public static int GetNextMoonRasi(GCEarthData ed, GregorianDateTime startDate, out GregorianDateTime nextDate)
        {
            double            phi = 30.0;
            double            l1, l2, longitudeMoon;
            double            jday = startDate.GetJulianComplete();
            GregorianDateTime d    = new GregorianDateTime();

            d.Set(startDate);
            double ayanamsa  = GCAyanamsha.GetAyanamsa(jday);
            double scan_step = 0.5;
            int    prev_naks = 0;
            int    new_naks  = -1;

            double            xj;
            GregorianDateTime xd = new GregorianDateTime();

            longitudeMoon = GCCoreAstronomy.GetMoonLongitude(d, ed);
            l1            = GCMath.putIn360(longitudeMoon - ayanamsa);
            prev_naks     = GCMath.IntFloor(l1 / phi);

            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();
                }

                longitudeMoon = GCCoreAstronomy.GetMoonLongitude(d, ed);
                l2            = GCMath.putIn360(longitudeMoon - ayanamsa);
                new_naks      = GCMath.IntFloor(l2 / phi);
                if (prev_naks != new_naks)
                {
                    jday = xj;
                    d.Set(xd);
                    scan_step *= 0.5;
                    counter++;
                    continue;
                }
                else
                {
                    l1 = l2;
                }
            }
            nextDate = new GregorianDateTime();
            nextDate.Set(d);
            return(new_naks);
        }
예제 #4
0
        public static string GetTextLongitude(double d)
        {
            int  a0, a1;
            char c0;

            c0 = d < 0.0 ? 'W' : 'E';
            d  = Math.Abs(d);
            a0 = GCMath.IntFloor(d);
            a1 = GCMath.IntFloor((d - a0) * 60 + 0.5);

            return(string.Format("{0}{1}{2:00}", a0, c0, a1));
        }
예제 #5
0
        private void CalculatePlanetRasi(int bodyId, GCLocation loc, GregorianDateTime vcEnd, GregorianDateTime vcAdd, GCConfigRatedEvents rec)
        {
            int    nData;
            double JD, JDE;

            JD    = vcAdd.GetJulian() - 0.5 - loc.OffsetUtcHours / 24.0;
            JDE   = vcEnd.GetJulian() + 0.5 - loc.OffsetUtcHours / 24.0;
            nData = GCMath.IntFloor(GCMath.putIn360(GCVSOPAstronomy.GetPlanetLongitude(bodyId, JD) - GCAyanamsha.GetAyanamsa(JD)) / 30.0);

            // initial rasi at the start date 00:00
            AddRating(JD, loc, rec.rateGrahaRasi[bodyId, nData], rec.rateGrahaRasi[bodyId, Prev(nData, 12)]);

            while ((JD = FindNextRasiChange(JD, JDE, bodyId, out nData)) < JDE)
            {
                AddRating(JD, loc, rec.rateGrahaRasi[bodyId, nData], rec.rateGrahaRasi[bodyId, Prev(nData, 12)]);
                JD += 1.0;
            }
        }
예제 #6
0
        /*********************************************************************/
        /*  Finds next time when rasi is changed                             */
        /*                                                                   */
        /*  startDate - starting date and time, timezone member must be valid */
        /*  zodiac [out] - found zodiac sign into which is changed           */
        /*                                                                   */
        /*********************************************************************/

        public static GregorianDateTime GetNextSankranti(GregorianDateTime startDate, GCEarthData earth, out int zodiac)
        {
            GregorianDateTime d = new GregorianDateTime();
            double            step = 1.0;
            int               count = 0;
            double            ld, prev;
            int               prev_rasi, new_rasi;
            GregorianDateTime prevday;

            d.Set(startDate);
            //d.ChangeTimeZone(0.0);
            //d.shour = 0.0;
            zodiac = 0;

            prev      = GCMath.putIn360(GCCoreAstronomy.GetSunLongitude(d, earth) - GCAyanamsha.GetAyanamsa(d.GetJulian()));
            prev_rasi = GCMath.IntFloor(prev / 30.0);

            while (count < 20)
            {
                prevday = new GregorianDateTime();
                prevday.Set(d);
                d.shour += step;
                if (d.shour > 1.0)
                {
                    d.shour -= 1.0;
                    d.NextDay();
                }

                ld       = GCMath.putIn360(GCCoreAstronomy.GetSunLongitude(d, earth) - GCAyanamsha.GetAyanamsa(d.GetJulian()));
                new_rasi = GCMath.IntFloor(ld / 30.0);

                if (prev_rasi != new_rasi)
                {
                    zodiac = new_rasi;
                    //v uplynulom dni je sankranti
                    step *= 0.5;
                    d.Set(prevday);
                    count++;
                    continue;
                }
            }

            return(d);
        }
예제 #7
0
        private void CalculatePlanetHouse(int bodyId, GCLocation loc, GregorianDateTime vcEnd, GregorianDateTime vcAdd, GCConfigRatedEvents rec)
        {
            int         nData;
            double      JD, JDE;
            GCEarthData earth = loc.GetEarthData();

            JD  = vcAdd.GetJulian() - 0.5 - loc.OffsetUtcHours / 24.0;
            JDE = vcEnd.GetJulian() + 0.5 - loc.OffsetUtcHours / 24.0;

            // initial rasi at the start date 00:00
            nData = GCMath.IntFloor(GetPlanetHouse(GCVSOPAstronomy.GetPlanetLongitude(bodyId, JD), JD, earth));
            AddRating(JD, loc, rec.rateGrahaHouse[bodyId, nData], rec.rateGrahaHouse[bodyId, Prev(nData, 12)]);

            while ((JD = FindNextHouseChange(JD, JDE, bodyId, earth, out nData)) < JDE)
            {
                AddRating(JD, loc, rec.rateGrahaHouse[bodyId, nData], rec.rateGrahaHouse[bodyId, Prev(nData, 12)]);
                JD += 1.0 / 24.0;
            }
        }
예제 #8
0
        public static string GetTimeZoneOffsetText(double d)
        {
            int a4, a5;
            int sig;

            if (d < 0.0)
            {
                sig = -1;
                d   = -d;
            }
            else
            {
                sig = 1;
            }
            a4 = GCMath.IntFloor(d);
            a5 = Convert.ToInt32((d - a4) * 60);

            return(string.Format("{0}{1}:{2:00}", (sig > 0 ? '+' : '-'), a4, a5));
        }
예제 #9
0
        public double FindNextHouseChange(double startJD, double endJD, int bodyId, GCEarthData earth, out int nNextHouse)
        {
            double jd = startJD;
            double A, B, B1;
            int    C, D;
            double step = 1.0 / 24.0;

            A   = GetPlanetHouse(GCVSOPAstronomy.GetPlanetLongitude(bodyId, jd), jd, earth);
            jd += step;
            B1  = A;
            B   = GetPlanetHouse(GCVSOPAstronomy.GetPlanetLongitude(bodyId, jd), jd, earth);
            C   = GCMath.IntFloor(A);
            D   = GCMath.IntFloor(B);

            while (jd < endJD && Math.Abs(B1 - B) >= 1 / 86400.0)
            {
                if (C == D)
                {
                    // goto next date
                    A = B;
                    C = D;
                }
                else if (C < D)
                {
                    jd    = jd - step;
                    step *= (D - A) / (B - A);
                }
                else // C > D
                {
                    jd    = jd - step;
                    step *= (A - C) / (A - B);
                }

                jd += step;
                B1  = B;
                B   = GetPlanetHouse(GCVSOPAstronomy.GetPlanetLongitude(bodyId, jd), jd, earth);
                D   = GCMath.IntFloor(B);
            }

            nNextHouse = GCMath.IntFloor(GetPlanetHouse(GCVSOPAstronomy.GetPlanetLongitude(bodyId, jd + 0.5 / 24.0), jd + 0.5 / 24.0, earth));
            return(jd);
        }
예제 #10
0
        public double FindNextRasiChange(double startJD, double endJD, int bodyId, out int nNextRasi)
        {
            double jd = startJD;
            double A, B, B1;
            int    C, D;
            double step = 1.0;

            A   = (GCVSOPAstronomy.GetPlanetLongitude(bodyId, jd) - GCAyanamsha.GetAyanamsa(jd)) / 30.0;
            jd += step;
            B1  = A;
            B   = (GCVSOPAstronomy.GetPlanetLongitude(bodyId, jd) - GCAyanamsha.GetAyanamsa(jd)) / 30.0;
            C   = GCMath.IntFloor(A);
            D   = GCMath.IntFloor(B);

            while (jd < endJD && Math.Abs(B1 - B) >= 1 / 86400.0)
            {
                if (C == D)
                {
                    // goto next date
                    A = B;
                    C = D;
                }
                else if (C < D)
                {
                    jd    = jd - step;
                    step *= (D - A) / (B - A);
                }
                else // C > D
                {
                    jd    = jd - step;
                    step *= (C - B) / (A - B);
                }

                jd += step;
                B1  = B;
                B   = (GCVSOPAstronomy.GetPlanetLongitude(bodyId, jd) - GCAyanamsha.GetAyanamsa(jd)) / 30.0;
                D   = GCMath.IntFloor(B);
            }

            nNextRasi = GCMath.IntFloor((GCVSOPAstronomy.GetPlanetLongitude(bodyId, jd + 0.1) - GCAyanamsha.GetAyanamsa(jd)) / 30.0);
            return(jd);
        }
예제 #11
0
        /*********************************************************************/
        /*                                                                   */
        /* Calculation of Rasi from sun-logitude and ayanamsa                */
        /*                                                                   */
        /*********************************************************************/

        public static int GetRasi(double SunLongitude, double Ayanamsa)
        {
            return(GCMath.IntFloor(GCMath.putIn360(SunLongitude - Ayanamsa) / 30.0));
        }
예제 #12
0
        /*********************************************************************/
        /*                                                                   */
        /*                                                                   */
        /*                                                                   */
        /*                                                                   */
        /*                                                                   */
        /*********************************************************************/

        public static double GetNextConjunction(GregorianDateTime test_date, out GregorianDateTime found, bool this_conj, GCEarthData earth)
        {
            double phi = 12.0;
            double l1, l2, longitudeSun, longitudeMoon;

            if (this_conj)
            {
                test_date.shour += 0.2;
                test_date.NormalizeValues();
            }


            double            jday = test_date.GetJulianComplete();
            double            xj;
            GregorianDateTime d = new GregorianDateTime();

            d.Set(test_date);
            GregorianDateTime xd        = new GregorianDateTime();
            double            scan_step = 1.0;
            int prev_tit = 0;
            int new_tit  = -1;

            longitudeMoon = GCCoreAstronomy.GetMoonLongitude(d, earth);
            longitudeSun  = GCSunData.GetSunLongitude(d);
            l1            = GCMath.putIn180(longitudeMoon - longitudeSun);
            prev_tit      = GCMath.IntFloor(l1 / phi);

            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();
                }

                longitudeMoon = GCCoreAstronomy.GetMoonLongitude(d, earth);
                longitudeSun  = GCSunData.GetSunLongitude(d);
                l2            = GCMath.putIn180(longitudeMoon - longitudeSun);
                new_tit       = GCMath.IntFloor(l2 / phi);

                if (prev_tit < 0 && new_tit >= 0)
                {
                    jday = xj;
                    d.Set(xd);
                    scan_step *= 0.5;
                    counter++;
                    continue;
                }
                else
                {
                    l1 = l2;
                }

                prev_tit = new_tit;
            }
            found = new GregorianDateTime();
            found.Set(d);
            return(longitudeSun);
        }