Beispiel #1
0
        public static void CalcMoonTimes(GPLocationProvider e, GPGregorianTime vc, out GPGregorianTime rise, out GPGregorianTime set)
        {
            double UT;

            rise = null;
            set  = null;

            // inicializacia prvej hodnoty ELEVATION
            vc.setDayHours(0.0);
            vc.normalizeValues();
            UT = vc.getJulianGreenwichTime();
            GPJulianTime start = new GPJulianTime();
            GPJulianTime time;

            start.setLocalJulianDay(vc.getJulianGreenwichTime());
            TRiseSet rs;

            set  = null;
            rise = null;
            time = GPAstroEngine.GetNextMoonEvent(start, e, out rs);
            while (time.getLocalJulianDay() < UT + 1)
            {
                GPGregorianTime gt = new GPGregorianTime(e, time);
                if (rs == TRiseSet.RISE && rise == null)
                {
                    rise = gt;
                }
                else if (rs == TRiseSet.SET && set == null)
                {
                    set = gt;
                }
                time = GPAstroEngine.GetNextMoonEvent(time, e, out rs);
            }
        }
Beispiel #2
0
        public static void FormatAppDayText(GPAppDayResults app, StringBuilder strResult)
        {
            GPAstroData     d = app.details;
            string          str;
            GPGregorianTime vc      = app.evente;
            StringBuilder   strText = strResult;

            int max = 0;

            foreach (GPStringPair rec in app.output)
            {
                if (!rec.Header)
                {
                    max = Math.Max(max, rec.Name.Length);
                }
            }
            max++;
            foreach (GPStringPair rec in app.output)
            {
                if (rec.Header)
                {
                    AddTextLine(strText, rec.Name);
                    AddTextLine(strText, string.Empty.PadLeft(rec.Name.Length, '-'));
                }
                else
                {
                    str = string.Format("{0} : {1}", rec.Name.PadLeft(max), rec.Value);
                    AddTextLine(strText, str);
                }
            }
        }
Beispiel #3
0
        public GPGregorianTime TimeByAddingHours(double dHours)
        {
            GPGregorianTime vc = new GPGregorianTime(this);

            vc.addDayHours(dHours / 24.0);
            return(vc);
        }
Beispiel #4
0
        /*********************************************************************/
        /*                                                                   */
        /*   finds next time when starts next yoga                           */
        /*                                                                   */
        /*   timezone is not changed                                         */
        /*                                                                   */
        /*   return value: index of yoga 0..26                               */
        /*                 or -1 if failed                                   */
        /*********************************************************************/

        public static int GetNextStart(GPGregorianTime startDate, out GPGregorianTime nextDate)
        {
            double          phi = 40 / 3.0;
            double          l1, l2, sunl;
            double          jday = startDate.getJulianGreenwichTime();
            double          xj;
            double          ayanamsa  = GPAyanamsa.GetAyanamsa(jday);
            GPMoon          moon      = new GPMoon();
            GPGregorianTime d         = new GPGregorianTime(startDate);
            GPGregorianTime xd        = new GPGregorianTime(startDate.getLocationProvider());
            double          scan_step = 0.5;
            int             prev_tit  = 0;
            int             new_tit   = -1;

            moon.MoonCalc(jday);
            sunl     = GPSun.GetSunLongitude(jday);
            l1       = GPMath.putIn360(moon.longitude_deg + sunl - 2 * ayanamsa);
            prev_tit = Convert.ToInt32(Math.Floor(l1 * 3 / 40.0));

            int counter = 0;

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

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

                moon.MoonCalc(jday);
                //SunPosition(d, ed, sun, d.shour - 0.5 + d.tzone/24.0);
                //l2 = put_in_360(moon.longitude_deg - sun.longitude_deg - 180.0);
                sunl = GPSun.GetSunLongitude(jday);
                l2   = GPMath.putIn360(moon.longitude_deg + sunl - 2 * ayanamsa);
                //Debugger.Log(0, "", "Current position: " + l2/12.0 + "   date: " + jday + "\n");
                new_tit = Convert.ToInt32(Math.Floor(l2 / phi));

                if (prev_tit != new_tit)
                {
                    jday = xj;
                    d.Copy(xd);
                    scan_step *= 0.5;
                    counter++;
                    continue;
                }
                else
                {
                    l1 = l2;
                }
            }
            nextDate = d;
            //	nextDate.shour += startDate.tzone / 24.0;
            //	nextDate.NormalizeValues();
            return(new_tit);
        }
Beispiel #5
0
        public static int FormatEventsXML(GPCoreEventResults inEvents, StringBuilder strXml)
        {
            int i;

            strXml.AppendFormat("<xml>\r\n<program version=\"{0}\">\r\n<location longitude=\"{1}\" latitude=\"{2}\" timezone=\"{3}\"/>\n"
                                , GPFileHelper.FileVersion, inEvents.m_location.getLocation(0).GetLongitudeEastPositive(),
                                inEvents.m_location.getLocation(0).GetLatitudeNorthPositive()
                                , inEvents.m_location.getLocation(0).getTimeZoneName());
            GPGregorianTime prevd = new GPGregorianTime(inEvents.m_location);

            prevd.setDate(1800, 1, 1);
            for (i = 0; i < inEvents.getCount(); i++)
            {
                GPCoreEvent dnr = inEvents.get(i);

                if (inEvents.b_sorted)
                {
                    if (prevd.getDay() != dnr.Time.getDay() || prevd.getMonth() != dnr.Time.getMonth() || prevd.getYear() != dnr.Time.getYear())
                    {
                        strXml.AppendFormat("\t<day date=\"{0}\" />\n", dnr.Time);
                    }
                    prevd = dnr.Time;
                }

                strXml.AppendFormat("\t<event type=\"{0}\" time=\"{1}\" />\n", dnr.getEventTitle(), dnr.Time.getLongTimeString());
            }

            strXml.Append("</xml>\n");

            return(1);
        }
Beispiel #6
0
        public void calculateCoordinatesMethodC(GPGregorianTime vct, double DayHours)
        {
            double DG  = GPMath.pi / 180;
            double RAD = 180 / GPMath.pi;

            // mean ecliptic longitude of the sun
            double mel = SunGetMeanLong(vct.getYear(), vct.getMonth(), vct.getDay()) + (360 / 365.25) * DayHours / 360.0;
            // ecliptic longitude of perigee
            double elp = SunGetPerigee(vct.getYear(), vct.getMonth(), vct.getDay());

            // mean anomaly of the sun
            double M = mel - elp;

            // equation of center
            double C = 1.9148 * GPMath.sinDeg(M)
                       + 0.02 * GPMath.sinDeg(2 * M)
                       + 0.0003 * GPMath.sinDeg(3 * M);

            // ecliptic longitude of the sun
            double els = 0;

            eclipticalLongitude = els = mel + C;

            // declination of the sun
            declination = GPMath.arcsinDeg(0.397948 * GPMath.sinDeg(eclipticalLongitude));

            // right ascension of the sun
            rightAscession = els - RAD * Math.Atan2(Math.Sin(2 * els * DG), 23.2377 + Math.Cos(2 * DG * els));

            // equation of time
            equationOfTime = rightAscession - mel;
            //equationOfTime = GPAstroEngine.getEquationOfTime(julianDay, right_asc_deg);
            //Debugger.Log(0,"", String.Format("{1}: EoTdiff = {0}\n", vct.getShortDateString(), equationOfTime - (right_asc_deg - mel)));
        }
Beispiel #7
0
        private void calculateRiseSetMethodA(GPGregorianTime vct, GPLocationProvider ed, double DayHours, GPSun sun, double DG, double RAD)
        {
            double time       = vct.getJulianLocalNoon() - 0.5 + DayHours / 360 - vct.getTimeZoneOffsetHours() / 24.0;
            double dLatitude  = ed.getLocation(time).GetLatitudeNorthPositive();
            double dLongitude = ed.getLocation(time).GetLongitudeEastPositive();
            //Debugger.Log(0,"",String.Format("{0}     {1} {2}\n", vct.getLongDateString(), dLatitude, dLongitude));
            // definition of event
            // eventdef = 0.0;
            // civil twilight eventdef = 0.10453;
            // nautical twilight eventdef = 0.20791;
            // astronomical twilight eventdef = 0.30902;
            // center of the sun on the horizont eventdef = 0.01454;
            double eventdef = 0.01454;

            double x = GPMath.tanDeg(dLatitude) * GPMath.tanDeg(sun.declination) + eventdef / (GPMath.cosDeg(dLatitude) * GPMath.cosDeg(sun.declination));

            if (x < -1.0 || x > 1.0)
            {
                // initial values for the case
                // that no rise no set for that day
                sun.sunrise_deg = -360;
                sun.noon_deg    = -360;
                sun.sunset_deg  = -360;
                return;
            }

            double hourAngle = GPMath.arcsinDeg(x);

            // time of sunrise
            sun.sunrise_deg = 90.0 - dLongitude - hourAngle + equationOfTime;
            // time of noon
            sun.noon_deg = 180.0 - dLongitude + equationOfTime;
            // time of sunset
            sun.sunset_deg = 270.0 - dLongitude + hourAngle + equationOfTime;
        }
Beispiel #8
0
        public static void FormatAppDayRtf(GPAppDayResults app, StringBuilder strResult)
        {
            //MOONDATA moon;
            //SUNDATA sun;
            GPAstroData     d = app.details;
            string          str;
            GPGregorianTime vc      = app.evente;
            StringBuilder   strText = strResult;

            strText.Remove(0, strText.Length);
            AppendRtfHeader(strText);


            foreach (GPStringPair rec in app.output)
            {
                if (rec.Header)
                {
                    strText.AppendFormat("\\par\\pard{{\\f2\\fs{0} {1}}", g_HeaderSize, rec.Name);
                    strText.AppendFormat("\\par\\pard\\f2\\fs{0}\r\n", g_TextSize);
                }
                else
                {
                    str = string.Format("\\tab {0} : {{\\b {1}}", rec.Name, rec.Value);
                    AddTextLineRtf(strText, str);
                }
            }


            strText.Append("}");
        }
Beispiel #9
0
        // return values
        // 0 - DST is off, yesterday was off
        // 1 - DST is on, yesterday was off
        // 2 - DST is on, yesterday was on
        // 3 - DST is off, yesterday was on
        public int GetDaylightChangeType(GPGregorianTime vc2)
        {
            long uToday     = vc2.getTimestamp();
            long uYesterday = uToday - 86400;

            Transition tzToday     = FindActiveTransition(uToday);
            Transition tzYesterday = FindActiveTransition(uYesterday);

            bool t1 = tzToday != null ? tzToday.Dst : false;
            bool t2 = tzYesterday != null ? tzYesterday.Dst : false;

            if (t1)
            {
                if (t2)
                {
                    return(2);
                }
                else
                {
                    return(1);
                }
            }
            else if (t2)
            {
                return(3);
            }
            else
            {
                return(0);
            }
        }
Beispiel #10
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);
        }
Beispiel #11
0
        /// <summary>
        /// Recalculation of sunrise time for given travelling
        /// </summary>
        /// <param name="sun"></param>
        /// <param name="locChange"></param>
        private static void recalculateSunriseTravel(GPSun sun, GPLocationChange locChange)
        {
            GPSun  newSun = new GPSun();
            double drStep = 0.5;
            double dr     = 0.0;
            int    steps  = 0;

            while (steps < 25)
            {
                GPLocation      lp = locChange.getTravellingLocation(dr);
                double          jd = locChange.julianStart + (locChange.julianEnd - locChange.julianStart) * dr;
                GPGregorianTime gt = new GPGregorianTime(lp);
                gt.setJulianGreenwichTime(jd);
                GPLocationProvider lpr = new GPLocationProvider(lp);
                newSun.calculateRise(sun.rise, lpr);
                newSun.updateSunriseTimes(sun.rise, lpr);

                if (gt.getJulianGreenwichTime() > newSun.rise.getJulianGreenwichTime())
                {
                    drStep = drStep / 2;
                    dr    -= drStep;
                }
                else
                {
                    dr += drStep;
                }

                steps++;
            }

            sun.rise                = newSun.rise;
            sun.sunrise_deg         = newSun.sunrise_deg;
            sun.eclipticalLongitude = newSun.eclipticalLongitude;
        }
Beispiel #12
0
        public int GetArg_Date(string str, out GPGregorianTime vc)
        {
            vc = new GPGregorianTime(GPLocation.getEmptyLocation());
            string[] parts = str.Replace('/', '-').Split('-');
            if (parts.Length < 3)
            {
                return(1);
            }
            int day, month, year;

            int.TryParse(parts[0], out day);
            if (day == 0)
            {
                day = 1;
            }
            int.TryParse(parts[1], out month);
            if (month == 0)
            {
                month = 1;
            }
            int.TryParse(parts[2], out year);

            vc.setDate(year, month, day);
            return(0);
        }
Beispiel #13
0
        /// <summary>
        /// get date text for today screen
        /// </summary>
        /// <param name="vc"></param>
        public static string getDateText(GPGregorianTime vc)
        {
            string str = string.Empty;

            getShared().TodayDate = new GPGregorianTime(vc);
            getShared().TodayDate.Today();

            int input = Convert.ToInt32(vc.getJulianLocalNoon());
            int today = Convert.ToInt32(getShared().TodayDate.getJulianLocalNoon());

            if ((vc.getDay() > 0) && (vc.getDay() < 32) && (vc.getMonth() > 0) && (vc.getMonth() < 13) && (vc.getYear() >= 1500) && (vc.getYear() < 4000))
            {
                if (input - today == 0)
                {
                    str = string.Format("{0} ({1}) - {2}", vc.ToString(), GPStrings.getString(43), GPStrings.getString(vc.getDayOfWeek()));
                }
                else if (input - today == 1)
                {
                    str = string.Format("{0} ({1}) - {2}", vc.ToString(), GPStrings.getString(854), GPStrings.getString(vc.getDayOfWeek()));
                }
                else if (input - today == -1)
                {
                    str = string.Format("{0} ({1}) - {2}", vc.ToString(), GPStrings.getString(853), GPStrings.getString(vc.getDayOfWeek()));
                }
                else
                {
                    str = string.Format("{0} - {1}", vc.ToString(), GPStrings.getString(vc.getDayOfWeek()));
                }
            }

            return(str);
        }
Beispiel #14
0
        public GPGregorianTime getSunriseTime()
        {
            GPGregorianTime vc = new GPGregorianTime(this.date);

            vc.setDayHours(astrodata.sun.getSunriseDayHours());
            return(vc);
        }
Beispiel #15
0
        public static void Report(GPLocationProvider loc, string prefix)
        {
            GPGregorianTime start = new GPGregorianTime(loc);
            GPGregorianTime end   = new GPGregorianTime(loc);

            start.setDate(2010, 1, 1);
            end.setDate(2015, 1, 1);

            GPCalendarResults calendar = new GPCalendarResults();

            calendar.CalculateCalendar(start, Convert.ToInt32(end.getJulianLocalNoon() - start.getJulianLocalNoon()));

            GPCoreEventResults coreEvents = new GPCoreEventResults();

            coreEvents.Sort(false);
            coreEvents.CalculateEvents(loc, start, end);

            string path = "d:\\gcal\\reports\\";

            if (Directory.Exists(path))
            {
                File.WriteAllText(Path.Combine(path, prefix + "-cal-" + loc.getCity() + ".txt"),
                                  FormaterInternal.getInternalDalendarData(calendar));
                File.WriteAllText(Path.Combine(path, prefix + "-eve-" + loc.getCity() + ".txt"),
                                  FormaterInternal.getInternalEventsText(coreEvents));
            }
        }
Beispiel #16
0
        /// <summary>
        /// Returns first day of gaurabda vaisnava calendar for given year
        /// </summary>
        /// <param name="loc"></param>
        /// <param name="year"></param>
        /// <returns></returns>
        public static DateTime GetFirstDayOfYear(GPLocationProvider loc, int year)
        {
            GPGregorianTime vcStart = GPGaurabdaYear.getFirstDayOfYear(loc, year);

            DateTime dt = new DateTime(vcStart.getYear(), vcStart.getMonth(), vcStart.getDay());

            return(dt);
        }
Beispiel #17
0
        /*********************************************************************/
        /*                                                                   */
        /*   finds previous time when starts next yoga                       */
        /*                                                                   */
        /*   timezone is not changed                                         */
        /*                                                                   */
        /*   return value: index of yoga 0..26                               */
        /*                 or -1 if failed                                   */
        /*********************************************************************/

        public static int GetPrevStart(GPGregorianTime startDate, out GPGregorianTime nextDate)
        {
            double          phi = 12.0;
            double          l1, l2, sunl;
            double          jday = startDate.getJulianGreenwichTime();
            double          xj;
            double          ayanamsa  = GPAyanamsa.GetAyanamsa(jday);
            GPMoon          moon      = new GPMoon();
            GPGregorianTime d         = new GPGregorianTime(startDate);
            GPGregorianTime xd        = new GPGregorianTime(startDate.getLocationProvider());
            double          scan_step = 0.5;
            int             prev_tit  = 0;
            int             new_tit   = -1;

            moon.MoonCalc(jday);
            sunl     = GPSun.GetSunLongitude(jday);
            l1       = GPMath.putIn360(moon.longitude_deg + sunl - 2 * ayanamsa);
            prev_tit = Convert.ToInt32(Math.Floor(l1 / phi));

            int counter = 0;

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

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

                moon.MoonCalc(jday);
                sunl    = GPSun.GetSunLongitude(jday);
                l2      = GPMath.putIn360(moon.longitude_deg + sunl - 2 * ayanamsa);
                new_tit = Convert.ToInt32(Math.Floor(l2 / phi));

                if (prev_tit != new_tit)
                {
                    jday = xj;
                    d.Copy(xd);
                    scan_step *= 0.5;
                    counter++;
                    continue;
                }
                else
                {
                    l1 = l2;
                }
            }
            nextDate = d;
            //	nextDate.shour += startDate.tzone / 24.0;
            //	nextDate.NormalizeValues();
            return(new_tit);
        }
Beispiel #18
0
 public void Copy(GPGregorianTime vc)
 {
     p_year  = vc.getYear();
     p_month = vc.getMonth();
     p_day   = vc.getDay();
     setDayHours(vc.getDayHours());
     setLocationProvider(vc.getLocationProvider());
     recalculateJulianGreenwichTime();
 }
Beispiel #19
0
 public void calculateRise(GPGregorianTime vct, GPLocationProvider ed)
 {
     //Debugger.Log(0,"", "stepA: ");
     calculateRiseSet(vct, ed, 0);
     //Debugger.Log(0, "", "stepB: ");
     calculateRiseSet(vct, ed, sunrise_deg - 180);
     //Debugger.Log(0, "", "stepC: ");
     calculateRiseSet(vct, ed, sunrise_deg - 180);
 }
Beispiel #20
0
        public int GetArg_Time(string str, out GPGregorianTime vc)
        {
            vc = new GPGregorianTime(GPLocation.getEmptyLocation());
            double l          = 0.0;
            double coma       = 10.0;
            bool   after_coma = false;
            bool   is_deg     = false;

            string s = str;

            foreach (char ch in str)
            {
                switch (ch)
                {
                case '0':
                case '1':
                case '2':
                case '3':
                case '4':
                case '5':
                case '6':
                case '7':
                case '8':
                case '9':
                    if (after_coma)
                    {
                        if (is_deg)
                        {
                            l += (ch - '0') * 5.0 / (coma * 3.0);
                        }
                        else
                        {
                            l += (ch - '0') / coma;
                        }
                        coma *= 10.0;
                    }
                    else
                    {
                        l = l * 10.0 + (ch - '0');
                    }
                    break;

                case ':':
                    after_coma = true;
                    is_deg     = true;
                    break;

                default:
                    return(SetArgLastError(14));
                }
            }

            vc.setDayHours(l / 24.0);

            return(0);
        }
Beispiel #21
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);
        }
Beispiel #22
0
        public static int getGaurabdaYear(GPGregorianTime vc, GPLocationProvider earth)
        {
            GPAstroData day = new GPAstroData();
            int         n;

            day.calculateDayData(vc, earth);
            day.determineMasa(vc, out n);

            return(n);
        }
Beispiel #23
0
        public double BiasHoursForDate(GPGregorianTime vc)
        {
            Transition trans = FindActiveTransition(vc.getTimestamp());

            if (trans != null)
            {
                return(Convert.ToDouble(trans.OffsetInSeconds - OffsetSeconds) / 3600.0);
            }
            return(0.0);
        }
Beispiel #24
0
        //===========================================================================
        //
        //===========================================================================

        public static void VCTIMEtoVATIME(GPGregorianTime vc, out GPVedicTime va, GPLocationProvider earth)
        {
            GPAstroData day = new GPAstroData();

            va = new GPVedicTime();

            day.calculateDayData(vc, earth);
            va.masa  = day.determineMasa(vc, out va.gyear);
            va.tithi = day.nTithi;
        }
Beispiel #25
0
        /*********************************************************************/
        /*                                                                   */
        /*   finds previous time when starts next naksatra                   */
        /*                                                                   */
        /*   timezone is not changed                                         */
        /*                                                                   */
        /*   return value: index of naksatra 0..26                           */
        /*                 or -1 if failed                                   */
        /*********************************************************************/

        public static int GetPrevNaksatra(GPGregorianTime startDate, out GPGregorianTime nextDate)
        {
            double          phi = 40.0 / 3.0;
            double          l1, l2;
            double          jday      = startDate.getJulianGreenwichTime();
            GPMoon          moon      = new GPMoon();
            GPGregorianTime d         = new GPGregorianTime(startDate);
            double          ayanamsa  = GPAyanamsa.GetAyanamsa(jday);
            double          scan_step = 0.5;
            int             prev_naks = 0;
            int             new_naks  = -1;

            double          xj;
            GPGregorianTime xd = new GPGregorianTime(startDate.getLocationProvider());

            moon.MoonCalc(jday);
            l1        = GPMath.putIn360(moon.longitude_deg - ayanamsa);
            prev_naks = Convert.ToInt32(Math.Floor(l1 / phi));

            int counter = 0;

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

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

                moon.MoonCalc(jday);
                l2       = GPMath.putIn360(moon.longitude_deg - ayanamsa);
                new_naks = Convert.ToInt32(Math.Floor(l2 / phi));

                if (prev_naks != new_naks)
                {
                    jday = xj;
                    d.Copy(xd);
                    scan_step *= 0.5;
                    counter++;
                    continue;
                }
                else
                {
                    l1 = l2;
                }
            }

            nextDate = d;
            return(new_naks);
        }
Beispiel #26
0
        public bool GetNaksatraTimeRange(GPLocation earth, out GPGregorianTime from, out GPGregorianTime to)
        {
            GPGregorianTime start = new GPGregorianTime(date);

            start.setDayHours(astrodata.sun.getSunriseDayHours());

            GPNaksatra.GetNextNaksatra(start, out to);
            GPNaksatra.GetPrevNaksatra(start, out from);

            return(true);
        }
Beispiel #27
0
        private bool AddEvent(GPGregorianTime inTime, int inType, string inData)
        {
            GPCoreEvent eve = new GPCoreEvent();

            eve.Time    = inTime;
            eve.strData = inData;
            eve.nType   = inType;

            p_events.Add(eve);
            return(true);
        }
Beispiel #28
0
        // return values
        // 0 - DST is off, yesterday was off
        // 1 - DST is on, yesterday was off
        // 2 - DST is on, yesterday was on
        // 3 - DST is off, yesterday was on
        public int GetDaylightChangeType(GPGregorianTime vcDay)
        {
            GPGregorianTime vcPrevDay = new GPGregorianTime(vcDay);

            vcPrevDay.PreviousDay();

            bool t1 = DaylightSavingInEFfect(vcDay);
            bool t2 = DaylightSavingInEFfect(vcPrevDay);

            return(t1 ? (t2 ? 2 : 1) : (t2 ? 3 : 0));
        }
Beispiel #29
0
        /*********************************************************************/
        /*                                                                   */
        /* Calculation of tithi, paksa, naksatra, yoga for given             */
        /*    Gregorian date                                                 */
        /*                                                                   */
        /*                                                                   */
        /*********************************************************************/

        public int calculateDayData(GPGregorianTime aDate, GPLocationProvider earth)
        {
            double          d;
            GPAstroData     day  = this;
            GPGregorianTime date = new GPGregorianTime(aDate);

            //	SUNDATA sun;

            // sun position on sunrise on that day
            sun.SunCalc(date, earth);
            date.setDayHours(sun.getSunriseDayHours());

            // date.shour is [0..1] time of sunrise in local timezone time
            jdate = date.getJulianGreenwichTime();

            // moon position at sunrise on that day
            day.moon.MoonCalc(jdate);

            // correct_parallax(day.moon, jdate, earth.latitude_deg, earth.longitude_deg);

            day.msDistance = GPMath.putIn360(day.moon.longitude_deg - day.sun.eclipticalLongitude - 180.0);
            day.msAyanamsa = GPAyanamsa.GetAyanamsa(jdate);

            // tithi
            d                = day.msDistance / 12.0;
            day.nTithi       = Convert.ToInt32(Math.Floor(d));
            day.nTithiElapse = GPMath.frac(d) * 100.0;
            day.nPaksa       = (day.nTithi >= 15) ? 1 : 0;


            // naksatra
            d                   = GPMath.putIn360(day.moon.longitude_deg - day.msAyanamsa);
            d                   = (d * 3.0) / 40.0;
            day.nNaksatra       = Convert.ToInt32(Math.Floor(d) + 0.1);
            day.nNaksatraElapse = GPMath.frac(d) * 100.0;

            // yoga
            d               = GPMath.putIn360(day.moon.longitude_deg + day.sun.eclipticalLongitude - 2 * day.msAyanamsa);
            d               = (d * 3.0) / 40.0;
            day.nYoga       = Convert.ToInt32(Math.Floor(d));
            day.nYogaElapse = GPMath.frac(d) * 100.0;

            // masa
            day.nMasa = -1;

            // rasi
            day.nSunRasi  = GPEngine.GetRasi(day.sun.eclipticalLongitude, day.msAyanamsa);
            day.nMoonRasi = GPEngine.GetRasi(day.moon.longitude_deg, day.msAyanamsa);

            setDate(date);

            return(1);
        }
Beispiel #30
0
        public static int calculateNaksatraAtMidnight(GPGregorianTime date, GPLocationProvider earth)
        {
            double d;
            double jdate;
            GPMoon moon = new GPMoon();
            GPSun  sun  = new GPSun();

            jdate = date.getJulianGreenwichNoon() + 0.5;
            moon.MoonCalc(jdate);
            d = GPMath.putIn360(moon.longitude_deg - GPAyanamsa.GetAyanamsa(jdate));
            return(Convert.ToInt32(Math.Floor((d * 3.0) / 40.0)));
        }