Пример #1
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;
        }
Пример #2
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);
        }
Пример #3
0
        protected double calculatePosition()
        {
            pMoon.MoonCalc(pJulianDate);
            pLastSunLongitude = GPSun.GetSunLongitude(pJulianDate);
            double l1 = GPMath.putIn360(pMoon.longitude_deg - pLastSunLongitude - opositeLongitude);

            return(GPMath.putIn180(l1));
        }
Пример #4
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);
        }
Пример #5
0
        public override double calculatePosition()
        {
            pMoon.MoonCalc(pJulianDate);
            //pSun.calculateCoordinates(pStartDate, pStartDate.getLocation(), pStartDate.getDayHours());
            //	SunPosition(d, ed, sun, d.shour - 0.5 + d.tzone/24.0);
            double l1 = GPMath.putIn360(pMoon.longitude_deg - /*pSun.eclipticalLongitude*/
                                        GPSun.GetSunLongitude(pJulianDate) - 180.0);

            return(l1 / 12.0);
        }
Пример #6
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)));
        }
Пример #7
0
        public static int WriteXML_Naksatra(StringBuilder doc, GPLocationProvider loc, GPGregorianTime vc, int nDaysCount)
        {
            doc.Append("<xml>\n");
            doc.Append("\t<request name=\"Naksatra\" version=\"" + GPFileHelper.FileVersion + "\">\n");
            doc.Append("\t\t<arg name=\"longitude\" val=\"" + loc.GetLongitudeEastPositive() + "\" />\n");
            doc.Append("\t\t<arg name=\"latitude\" val=\"" + loc.GetLatitudeNorthPositive() + "\" />\n");
            doc.Append("\t\t<arg name=\"timezone\" val=\"" + loc.getTimeZone().OffsetSeconds / 60 + "\" />\n");
            doc.Append("\t\t<arg name=\"startdate\" val=\"" + vc + "\" />\n");
            doc.Append("\t\t<arg name=\"daycount\" val=\"" + nDaysCount + "\" />\n");
            doc.Append("\t</request>\n");
            doc.Append("\t<result name=\"Naksatra\">\n");

            GPGregorianTime d   = new GPGregorianTime(vc);
            GPGregorianTime dn  = new GPGregorianTime(loc);
            GPSun           sun = new GPSun();
            int             nak;

            for (int i = 0; i < 30; i++)
            {
                nak = GPNaksatra.GetNextNaksatra(d, out dn);
                d.Copy(dn);
                doc.Append("\t\t<day date=\"" + d + "\">\n");
                //str = string.Format("{}.{}.{}", d.day, d.month, d.year);
                //n = m_list.InsertItem(50, GPNaksatra.GetName(nak));
                //m_list.SetItemText(n, 1, str);
                doc.Append("\t\t\t<naksatra id=\"" + nak + "\" name=\"" + GPNaksatra.getName(nak) + "\"\n");
                //dt.SetDegTime(d.getDayHours() * 360);
                //time_print(str, dt);
                doc.Append("\t\t\t\tstarttime=\"" + d.getShortTimeString() + "\" />\n");
                //m_list.SetItemText(n, 2, str);

                // sunrise time get
                sun.SunCalc(d, loc);
                //time_print(str, sun.rise);
                //m_list.SetItemText(n, 3, str);
                doc.Append("\t\t\t<sunrise time=\"" + sun.rise + "\" />\n");

                doc.Append("\t\t</day>\n");
                // increment for non-duplication of naksatra
                d.Copy(dn);
                d.setDayHours(d.getDayHours() + 1.0 / 8.0);
            }


            doc.Append("\t</result>\n");
            doc.Append("</xml>\n");


            return(1);
        }
Пример #8
0
        protected void copyFrom(GPSun sn)
        {
            base.copyFrom(sn);

            this.arunodaya          = new GPGregorianTime(sn.arunodaya);
            this.arunodaya_deg      = sn.arunodaya_deg;
            this.DayLength          = sn.DayLength;
            this.length_deg         = sn.length_deg;
            this.longitude_arun_deg = sn.longitude_arun_deg;
            this.longitude_set_deg  = sn.longitude_set_deg;
            this.noon        = new GPGregorianTime(sn.noon);
            this.rise        = new GPGregorianTime(sn.rise);
            this.set         = new GPGregorianTime(sn.set);
            this.sunrise_deg = sn.sunrise_deg;
            this.sunset_deg  = sn.sunset_deg;
        }
Пример #9
0
        // return values are in sun.arunodaya, sun.rise, sun.set, sun.noon, sun.length
        // if values are less than zero, that means, no sunrise, no sunset in that day
        //
        // brahma 1 = calculation at brahma muhurta begining
        // brahma 0 = calculation at sunrise



        public void SunCalc(GPGregorianTime vct, GPLocationProvider earth)
        {
            if (sunPosMethod == SUNPOSMETHOD_CALCULATOR)
            {
                GPSun s_rise = new GPSun();
                GPSun s_set  = new GPSun();

                // first calculation
                // for 12:00 universal time
                s_rise.calculateRise(vct, earth);

                // first calculation
                // for 12:00 universal time
                s_set.calculateSet(vct, earth);

                // calculate times
                longitude_arun_deg  = s_rise.eclipticalLongitude - (24.0 / 365.25);
                eclipticalLongitude = s_rise.eclipticalLongitude;
                rightAscession      = s_rise.rightAscession;
                longitude_set_deg   = s_set.eclipticalLongitude;

                sunrise_deg = s_rise.sunrise_deg;
                sunset_deg  = s_set.sunset_deg;
            }
            else
            {
                calculateRiseSet(vct, earth, 180);
                double gmt = vct.getJulianGreenwichNoon();

                longitude_arun_deg  = GPAstroEngine.sunLongitudeMethodM(julianDayRise - 96 / 1440.0);
                eclipticalLongitude = GPAstroEngine.sunLongitudeMethodM(julianDayRise);
                longitude_set_deg   = GPAstroEngine.sunLongitudeMethodM(julianDaySet);
            }

            updateSunriseTimes(vct, earth);
            updateNoonTimes(vct, earth);
            updateSetTimes(vct, earth);

            List <GPLocationChange> chr = earth.getChangesForJulianDay(arunodaya.getJulianGreenwichNoon());

            processTravellingChanges(chr);

            // finally calculate length of the daylight
            DayLength = (set.getJulianGreenwichTime() - rise.getJulianGreenwichTime()) * 24.0;
        }
Пример #10
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 GPGregorianTime GetNextSankranti(GPGregorianTime startDate, out int zodiac)
        {
            GPGregorianTime d;
            double          step = 1.0;
            int             count = 0;
            double          ld, prev;
            int             prev_rasi, new_rasi;
            GPGregorianTime prevday = new GPGregorianTime(startDate.getLocation());

            zodiac = 0;
            d      = new GPGregorianTime(startDate);
            double jdate = d.getJulianGreenwichTime();

            prev      = GPMath.putIn360(GPSun.GetSunLongitude(jdate) - GPAyanamsa.GetAyanamsa(jdate));
            prev_rasi = Convert.ToInt32(Math.Floor(prev / 30.0));

            while (count < 20)
            {
                prevday.Copy(d);
                d.setDayHours(d.getDayHours() + step);
                if (d.getDayHours() > 1.0)
                {
                    d.setDayHours(d.getDayHours() - 1.0);
                    d.NextDay();
                }
                jdate    = d.getJulianGreenwichTime();
                ld       = GPMath.putIn360(GPSun.GetSunLongitude(jdate) - GPAyanamsa.GetAyanamsa(jdate));
                new_rasi = Convert.ToInt32(Math.Floor(ld / 30.0));

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

            return(d);
        }
Пример #11
0
 public void Copy(GPAstroData dt)
 {
     this.setLocation(dt.getLocation());
     this.setDate(dt.getDate());
     this.jdate           = dt.jdate;
     this.moon            = new GPMoon(dt.moon);
     this.msAyanamsa      = dt.msAyanamsa;
     this.msDistance      = dt.msDistance;
     this.nGaurabdaYear   = dt.nGaurabdaYear;
     this.nMasa           = dt.nMasa;
     this.nMoonRasi       = dt.nMoonRasi;
     this.nNaksatra       = dt.nNaksatra;
     this.nNaksatraElapse = dt.nNaksatraElapse;
     this.nPaksa          = dt.nPaksa;
     this.nSunRasi        = dt.nSunRasi;
     this.nTithi          = dt.nTithi;
     this.nTithiElapse    = dt.nTithiElapse;
     this.nYoga           = dt.nYoga;
     this.nYogaElapse     = dt.nYogaElapse;
     this.sun             = new GPSun(dt.sun);
 }
Пример #12
0
        /// <summary>
        /// recalculation of arunodaya time for given travelling
        /// </summary>
        /// <param name="sun"></param>
        /// <param name="locChange"></param>
        private static void recalculateArunodayaTravel(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);
                //                    Debugger.Log(0, "", String.Format("ROW: {0} {1}   {2}  {3}\n", lp.getLongitudeString(), lp.getLatitudeString(),
                //                        newSun.rise.getLongTimeString(), gt.getLongTimeString()));

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

                steps++;
            }

            sun.arunodaya          = newSun.arunodaya;
            sun.arunodaya_deg      = newSun.arunodaya_deg;
            sun.longitude_arun_deg = newSun.longitude_arun_deg;
        }
Пример #13
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;
        }
Пример #14
0
        public static int WriteXML_GaurabdaNextTithi(StringBuilder doc, GPLocationProvider loc, GPGregorianTime vcStart, GPVedicTime vaStart)
        {
            int gmasa, gpaksa, gtithi;


            gmasa  = vaStart.masa;
            gpaksa = vaStart.tithi / 15;
            gtithi = vaStart.tithi % 15;

            doc.Append("<xml>\n");
            doc.Append("\t<request name=\"Tithi\" version=\"" + GPFileHelper.FileVersion + "\">\n");
            doc.Append("\t\t<arg name=\"longitude\" val=\"" + loc.GetLongitudeEastPositive() + "\" />\n");
            doc.Append("\t\t<arg name=\"latitude\" val=\"" + loc.GetLatitudeNorthPositive() + "\" />\n");
            doc.Append("\t\t<arg name=\"timezone\" val=\"" + loc.getTimeZone().OffsetSeconds / 60 + "\" />\n");
            doc.Append("\t\t<arg name=\"start date\" val=\"" + vcStart + "\" />\n");
            doc.Append("\t\t<arg name=\"masa\" val=\"" + gmasa + "\" />\n");
            doc.Append("\t\t<arg name=\"paksa\" val=\"" + gpaksa + "\" />\n");
            doc.Append("\t\t<arg name=\"tithi\" val=\"" + gtithi + "\" />\n");
            doc.Append("\t</request>\n");
            doc.Append("\t<result name=\"Tithi\">\n");

            GPGregorianTime vcs   = new GPGregorianTime(loc);
            GPGregorianTime vce   = new GPGregorianTime(loc);
            GPGregorianTime today = new GPGregorianTime(loc);
            GPSun           sun   = new GPSun();
            int             A;
            double          sunrise;
            GPAstroData     day = new GPAstroData();
            int             oTithi, oPaksa, oMasa, oYear;

            today.Copy(vcStart);
            today.PreviousDay();
            vcStart.SubDays(15);
            for (A = 0; A <= 3; A++)
            {
                vcs = GPTithi.CalcTithiEndEx(vcStart, 0, gmasa, gpaksa, gtithi, loc, out vce);
                if (!vcs.IsBeforeThis(today))
                {
                    oTithi = gpaksa * 15 + gtithi;
                    oMasa  = gmasa;
                    oPaksa = gpaksa;
                    oYear  = 0;
                    doc.Append("\t<celebration\n");
                    //		doc.Append( "\t\t<tithi\n");
                    doc.Append("\t\trtithi=\"" + GPTithi.getName(oTithi) + "\"\n");
                    doc.Append("\t\trmasa=\"" + GPMasa.GetName(oMasa) + "\"\n");
                    doc.Append("\t\trpaksa=\"" + GPPaksa.getName(oPaksa) + "\"\n");
                    // test ci je ksaya
                    today.Copy(vcs);
                    today.setDayHours(0.5);
                    sun.SunCalc(today, loc);
                    sunrise = sun.getSunriseDayHours();
                    if (sunrise < vcs.getDayHours())
                    {
                        today.Copy(vce);
                        sun.SunCalc(today, loc);
                        sunrise = sun.getSunriseDayHours();
                        if (sunrise < vce.getDayHours())
                        {
                            // normal type
                            vcs.NextDay();
                            doc.Append("\t\ttype=\"normal\"\n");
                        }
                        else
                        {
                            // ksaya
                            vcs.NextDay();
                            day.calculateDayData(vcs, loc);
                            oTithi = day.nTithi;
                            oPaksa = day.nPaksa;
                            oMasa  = day.determineMasa(vcs, out oYear);
                            doc.Append("\t\ttype=\"ksaya\"\n");
                        }
                    }
                    else
                    {
                        // normal, alebo prvy den vriddhi
                        today.Copy(vce);
                        sun.SunCalc(today, loc);
                        if (sun.getSunriseDayHours() < vce.getDayHours())
                        {
                            // first day of vriddhi type
                            doc.Append("\t\ttype=\"vriddhi\"\n");
                        }
                        else
                        {
                            // normal
                            doc.Append("\t\ttype=\"normal\"\n");
                        }
                    }
                    doc.Append("\t\tdate=\"" + vcs + "\"\n");
                    doc.Append("\t\totithi=\"" + GPTithi.getName(oTithi) + "\"\n");
                    doc.Append("\t\tomasa=\"" + GPMasa.GetName(oMasa) + "\"\n");
                    doc.Append("\t\topaksa=\"" + GPPaksa.getName(oPaksa) + "\"\n");
                    doc.Append("\t/>\n");
                    break;
                }
                else
                {
                    vcStart.Copy(vcs);
                    vcs.NextDay();
                }
            }

            doc.Append("\t</result>\n");
            doc.Append("</xml>\n");


            return(1);
        }
Пример #15
0
        public override double calculatePosition()
        {
            double prev = GPMath.putIn360(GPSun.GetSunLongitude(pJulianDate) - GPAyanamsa.GetAyanamsa(pJulianDate));

            return(prev / 30.0);
        }
Пример #16
0
        public void CalculateEvents(GPLocationProvider loc, GPGregorianTime vcStart, GPGregorianTime vcEnd)
        {
            GPCoreEventResults inEvents = this;
            GPLocationProvider earth    = loc;
            GPGregorianTime    vc       = new GPGregorianTime(loc);
            GPSun sun = new GPSun();
            //int ndst = 0;
            int nData;

            inEvents.clear();
            inEvents.m_location = loc;
            inEvents.m_vcStart  = vcStart;
            inEvents.m_vcEnd    = vcEnd;

            GPGregorianTime vcAdd  = new GPGregorianTime(loc);
            GPGregorianTime vcTemp = null;
            GPGregorianTime vcNext = new GPGregorianTime(loc);

            vc.Copy(vcStart);

            if (GPDisplays.CoreEvents.Sunrise())
            {
                vcAdd.Copy(vc);
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    sun.SunCalc(vcAdd, earth);

                    vcTemp = new GPGregorianTime(sun.arunodaya);
                    inEvents.AddEvent(vcTemp, GPConstants.CCTYPE_S_ARUN, 0);

                    //GPJulianTime tr, tt, ts;
                    //GPAstroEngine.CalculateTimeSun(vcTemp, vcTemp.getLocation(), out tr, out tt, out ts);
                    vcTemp = new GPGregorianTime(sun.rise);
                    //vcTemp = new GPGregorianTime(vcTemp.getLocation(), tr);
                    inEvents.AddEvent(vcTemp, GPConstants.CCTYPE_S_RISE, 0);

                    vcTemp = new GPGregorianTime(sun.noon);
                    //vcTemp = new GPGregorianTime(vcTemp.getLocation(), tt);
                    inEvents.AddEvent(vcTemp, GPConstants.CCTYPE_S_NOON, 0);

                    vcTemp = new GPGregorianTime(sun.set);
                    //vcTemp = new GPGregorianTime(vcTemp.getLocation(), ts);
                    inEvents.AddEvent(vcTemp, GPConstants.CCTYPE_S_SET, 0);

                    vcAdd.NextDay();
                }
            }

            if (GPDisplays.CoreEvents.Tithi())
            {
                GPTithi te = new GPTithi();
                te.setStartDate(vc);
                vcAdd = te.getNext();
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = te.getCurrentPosition();
                    //ndst = loc.getTimeZone().GetDaylightChangeType(vcNext);
                    inEvents.AddEvent(vcAdd, GPConstants.CCTYPE_TITHI, nData);
                    vcAdd = te.getNext();
                }
            }

            if (GPDisplays.CoreEvents.Naksatra())
            {
                GPNaksatra te = new GPNaksatra();
                te.setStartDate(vc);
                vcAdd = te.getNext();
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = te.getCurrentNaksatra();
                    //ndst = loc.getTimeZone().GetDaylightChangeType(vcNext);
                    inEvents.AddEvent(vcAdd, GPConstants.CCTYPE_NAKS, nData);
                    vcAdd = te.getNext();
                }
            }

            if (GPDisplays.CoreEvents.Sankranti())
            {
                GPSankranti te = new GPSankranti();
                te.setStartDate(vc);
                vcAdd = te.getNext();
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = te.getCurrentPosition();
                    //ndst = loc.getTimeZone().GetDaylightChangeType(vcNext);
                    inEvents.AddEvent(vcAdd, GPConstants.CCTYPE_SANK, nData);
                    vcAdd = te.getNext();
                }
            }

            if (GPDisplays.CoreEvents.Conjunction())
            {
                double[]      times = null;
                GPConjunction te    = new GPConjunction();
                te.setStartDate(vc);
                vcAdd = te.getNext();
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = te.getCurrentPosition();
                    //ndst = loc.getTimeZone().GetDaylightChangeType(vcNext);
                    inEvents.AddEvent(vcAdd, GPConstants.CCTYPE_CONJ, nData);

                    if (GPDisplays.CoreEvents.SunEclipse())
                    {
                        GPAstroEngine.CalculateTimesSunEclipse(vcAdd.getJulianGreenwichTime(), vcAdd.getLocation(), out times);
                        if (times != null && times[2] > 0)
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                if (times[i] > 0)
                                {
                                    GPGregorianTime gt = new GPGregorianTime(vcAdd.getLocation());
                                    gt.setJulianGreenwichTime(new GPJulianTime(times[i], 0.0));
                                    inEvents.AddEvent(gt, GPConstants.SUNECLIPSE_CONSTS[i], 0);
                                }
                            }
                        }
                    }

                    vcAdd = te.getNext();
                }
            }


            // moon eclipses
            if (GPDisplays.CoreEvents.MoonEclipse())
            {
                double[]      times = null;
                GPConjunction te    = new GPConjunction();
                te.setOpositeConjunction(true);
                te.setStartDate(vc);
                vcAdd = te.getNext();
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    GPAstroEngine.CalculateTimesMoonEclipse(vcAdd.getJulianGreenwichTime(), vcAdd.getLocation(), out times);
                    if (times != null && times[4] > 0)
                    {
                        for (int i = 0; i < 9; i++)
                        {
                            if (times[i] > 0 && GPConstants.MOONECLIPSE_CONSTS[i] > 0)
                            {
                                GPGregorianTime gt = new GPGregorianTime(vcAdd.getLocation());
                                gt.setJulianGreenwichTime(new GPJulianTime(times[i], 0.0));
                                inEvents.AddEvent(gt, GPConstants.MOONECLIPSE_CONSTS[i], 0);
                            }
                        }
                    }

                    vcAdd = te.getNext();
                }
            }

            // rise and set of the moon
            if (GPDisplays.CoreEvents.Moonrise())
            {
                GPJulianTime julian    = vc.getJulian();
                GPJulianTime julianEnd = vcEnd.getJulian();
                GPJulianTime nextJulian;
                TRiseSet     kind;

                while (julian.getGreenwichJulianDay() < julianEnd.getGreenwichJulianDay())
                {
                    nextJulian = GPAstroEngine.GetNextMoonEvent(julian, vc.getLocationProvider(), out kind);
                    if (kind == TRiseSet.RISE)
                    {
                        inEvents.AddEvent(new GPGregorianTime(loc, nextJulian), GPConstants.CoreEventMoonRise, 0);
                    }
                    else if (kind == TRiseSet.SET)
                    {
                        inEvents.AddEvent(new GPGregorianTime(loc, nextJulian), GPConstants.CoreEventMoonSet, 0);
                    }
                    julian.setGreenwichJulianDay(nextJulian.getGreenwichJulianDay() + 10.0 / 1440.0);
                }
            }

            // travellings
            {
                GPJulianTime julian = vc.getJulian();
                GPJulianTime julianEnd = vcEnd.getJulian();
                double       start, end;

                start = julian.getGreenwichJulianDay();
                end   = julianEnd.getGreenwichJulianDay();

                for (int i = 0; i < loc.getChangeCount(); i++)
                {
                    GPLocationChange chn = loc.getChangeAtIndex(i);
                    if ((chn.julianStart >= start && chn.julianStart <= end) ||
                        (chn.julianStart >= start && chn.julianEnd <= end))
                    {
                        GPGregorianTime startTime = new GPGregorianTime(chn.LocationA);
                        startTime.setJulianGreenwichTime(new GPJulianTime(chn.julianStart, 0));
                        GPGregorianTime endTime = new GPGregorianTime(chn.LocationB);
                        endTime.setJulianGreenwichTime(new GPJulianTime(chn.julianEnd, 0));
                        inEvents.AddEvent(startTime, GPConstants.CCTYPE_TRAVELLING_START, 0);
                        inEvents.AddEvent(endTime, GPConstants.CCTYPE_TRAVELLING_END, 0);
                    }
                }
            }

            // eventual sorting
            inEvents.Sort(GPDisplays.CoreEvents.Sort());
        }
Пример #17
0
        /// <summary>
        /// goes throuhg list of travellings and for each travelling tests
        /// whether it interferes with times for sun (arunodaya, sunrise, noon, sunset)
        /// </summary>
        /// <param name="chr"></param>
        private void processTravellingChanges(List <GPLocationChange> chr)
        {
            foreach (GPLocationChange locc in chr)
            {
                GPLocationProvider prov = new GPLocationProvider(locc.LocationA);
                GPSun newSun            = new GPSun();
                newSun.SunCalc(rise, prov);
                double[] t = new double[4];
                t[0] = newSun.arunodaya.getJulianGreenwichTime();
                t[1] = newSun.rise.getJulianGreenwichTime();
                t[2] = newSun.noon.getJulianGreenwichTime();
                t[3] = newSun.set.getJulianGreenwichTime();

                for (int i = 0; i < 4; i++)
                {
                    if (locc.julianStart > t[i])
                    {
                        t[i] = -1;
                    }
                }

                prov   = new GPLocationProvider(locc.LocationB);
                newSun = new GPSun();
                newSun.SunCalc(rise, prov);
                double[] s = new double[4];
                s[0] = newSun.arunodaya.getJulianGreenwichTime();
                s[1] = newSun.rise.getJulianGreenwichTime();
                s[2] = newSun.noon.getJulianGreenwichTime();
                s[3] = newSun.set.getJulianGreenwichTime();

                for (int i = 0; i < 4; i++)
                {
                    if (locc.julianEnd < s[i])
                    {
                        s[i] = -1;
                    }
                }

                bool[] b = new bool[4];
                for (int i = 0; i < 4; i++)
                {
                    b[i] = (t[i] > 0 && s[i] > 0);
                }

                if (b[0])
                {
                    recalculateArunodayaTravel(this, locc);
                }

                if (b[1])
                {
                    recalculateSunriseTravel(this, locc);
                }

                if (b[2])
                {
                    recalculateNoonTravel(this, locc);
                }

                if (b[3])
                {
                    recalculateSetTravel(this, locc);
                }
            }
        }
Пример #18
0
 public GPSun(GPSun sn)
 {
     copyFrom(sn);
 }
Пример #19
0
        public static int WriteXML_GaurabdaTithi(StringBuilder doc, GPLocationProvider loc, GPVedicTime vaStart, GPVedicTime vaEnd)
        {
            int gyearA = vaStart.gyear;
            int gyearB = vaEnd.gyear;
            int gmasa  = vaStart.masa;
            int gpaksa = vaStart.tithi / 15;
            int gtithi = vaStart.tithi % 15;

            if (gyearB < gyearA)
            {
                gyearB = gyearA;
            }



            doc.Append("<xml>\n");
            doc.Append("\t<request name=\"Tithi\" version=\"" + GPFileHelper.FileVersion + "\">\n");
            doc.Append("\t\t<arg name=\"longitude\" val=\"" + loc.getLocation(0).GetLongitudeEastPositive() + "\" />\n");
            doc.Append("\t\t<arg name=\"latitude\" val=\"" + loc.getLocation(0).GetLatitudeNorthPositive() + "\" />\n");
            doc.Append("\t\t<arg name=\"timezone\" val=\"" + loc.getLocation(0).getTimeZone().OffsetSeconds / 60 + "\" />\n");
            if (gyearA > 1500)
            {
                doc.Append("\t\t<arg name=\"year-start\" val=\"" + gyearA + "\" />\n");
                doc.Append("\t\t<arg name=\"year-end\" val=\"" + gyearB + "\" />\n");
            }
            else
            {
                doc.Append("\t\t<arg name=\"gaurabdayear-start\" val=\"" + gyearA + "\" />\n");
                doc.Append("\t\t<arg name=\"gaurabdayear-end\" val=\"" + gyearB + "\" />\n");
            }
            doc.Append("\t\t<arg name=\"masa\" val=\"" + gmasa + "\" />\n");
            doc.Append("\t\t<arg name=\"paksa\" val=\"" + gpaksa + "\" />\n");
            doc.Append("\t\t<arg name=\"tithi\" val=\"" + gtithi + "\" />\n");
            doc.Append("\t</request>\n");
            doc.Append("\t<result name=\"Tithi\">\n");


            GPGregorianTime vcs = new GPGregorianTime(loc), vce = new GPGregorianTime(loc), today = new GPGregorianTime(loc);
            GPSun           sun = new GPSun();
            int             A, B;
            double          sunrise;
            GPAstroData     day = new GPAstroData();
            int             oTithi, oPaksa, oMasa, oYear;

            if (gyearA > 1500)
            {
                A = gyearA - 1487;
                B = gyearB - 1485;
            }
            else
            {
                A = gyearA;
                B = gyearB;
            }

            for (; A <= B; A++)
            {
                vcs = GPTithi.CalcTithiEnd(A, gmasa, gpaksa, gtithi, loc, out vce);
                if (gyearA > 1500)
                {
                    if ((vcs.getYear() < gyearA) || (vcs.getYear() > gyearB))
                    {
                        continue;
                    }
                }
                oTithi = gpaksa * 15 + gtithi;
                oMasa  = gmasa;
                oPaksa = gpaksa;
                oYear  = 0;
                doc.Append("\t<celebration\n");
                doc.Append("\t\trtithi=\"" + GPTithi.getName(oTithi) + "\"\n");
                doc.Append("\t\trmasa=\"" + GPMasa.GetName(oMasa) + "\"\n");
                doc.Append("\t\trpaksa=\"" + GPPaksa.getName(oPaksa) + "\"\n");
                // test ci je ksaya
                today.Copy(vcs);
                today.setDayHours(0.5);
                sun.SunCalc(today, loc);
                sunrise = sun.getSunriseDayHours();
                if (sunrise < vcs.getDayHours())
                {
                    today.Copy(vce);
                    sun.SunCalc(today, loc);
                    sunrise = sun.getSunriseDayHours();
                    if (sunrise < vce.getDayHours())
                    {
                        // normal type
                        vcs.NextDay();
                        doc.Append("\t\ttype=\"normal\"\n");
                    }
                    else
                    {
                        // ksaya
                        vcs.NextDay();
                        day.calculateDayData(vcs, loc);
                        oTithi = day.nTithi;
                        oPaksa = day.nPaksa;
                        oMasa  = day.determineMasa(vcs, out oYear);
                        doc.Append("\t\ttype=\"ksaya\"\n");
                    }
                }
                else
                {
                    // normal, alebo prvy den vriddhi
                    today.Copy(vce);
                    sun.SunCalc(today, loc);
                    if (sun.getSunriseDayHours() < vce.getDayHours())
                    {
                        // first day of vriddhi type
                        doc.Append("\t\ttype=\"vriddhi\"\n");
                    }
                    else
                    {
                        // normal
                        doc.Append("\t\ttype=\"normal\"\n");
                    }
                }
                doc.Append("\t\tdate=\"" + vcs + "\"\n");
                doc.Append("\t\totithi=\"" + GPTithi.getName(oTithi) + "\"\n");
                doc.Append("\t\tomasa=\"" + GPMasa.GetName(oMasa) + "\"\n");
                doc.Append("\t\topaksa=\"" + GPPaksa.getName(oPaksa) + "\"\n");
                doc.Append("\t/>\n");
                //		doc.Append( "\t\t</celebration>\n");
            }


            doc.Append("\t</result>\n");
            doc.Append("</xml>\n");

            return(1);
        }