Beispiel #1
0
        public static void calc_geocentric(ref double longitude, ref double latitude, ref double rektaszension, ref double declination, double date)
        {
            //var
            double epsilon;      //: extended;
            double delta_phi;    //: extended;
            double alpha, delta; //: extended;

            calc_epsilon_phi(date, out delta_phi, out epsilon);
            longitude = GPMath.putIn360(longitude + delta_phi);

            alpha = GPMath.arctan2Deg(GPMath.sinDeg(longitude) * GPMath.cosDeg(epsilon) - GPMath.tanDeg(latitude) * GPMath.sinDeg(epsilon), GPMath.cosDeg(longitude));

            delta = GPMath.arcsinDeg(GPMath.sinDeg(latitude) * GPMath.cosDeg(epsilon) + GPMath.cosDeg(latitude) * GPMath.sinDeg(epsilon) * GPMath.sinDeg(longitude));

            rektaszension = alpha;
            declination   = delta;

            double xg, yg, zg;

            xg = GPMath.cosDeg(longitude) * GPMath.cosDeg(latitude);
            yg = GPMath.sinDeg(longitude) * GPMath.cosDeg(latitude);
            zg = GPMath.sinDeg(latitude);

            alpha = GPMath.arctan2Deg(yg * GPMath.cosDeg(epsilon) - zg * GPMath.sinDeg(epsilon), GPMath.cosDeg(longitude) * GPMath.cosDeg(latitude));
        }
        /// <summary>
        /// Based on Chapter 39, Meeus and Chapter 10
        /// </summary>
        /// <param name="obs"></param>
        public void makeTopocentric(GPObserver obs)
        {
            double       u, h, delta_alpha;
            double       rho_sin, rho_cos;
            const double b_a = 0.99664719;

            // geocentric position of observer on the earth surface
            // 10.1 - 10.3
            u       = GPMath.arctanDeg(b_a * b_a * GPMath.tanDeg(obs.GetLatitudeNorthPositive()));
            rho_sin = b_a * GPMath.sinDeg(u) + obs.GetAltitude() / 6378140.0 * GPMath.sinDeg(obs.GetLatitudeNorthPositive());
            rho_cos = GPMath.cosDeg(u) + obs.GetAltitude() / 6378140.0 * GPMath.cosDeg(obs.GetLatitudeNorthPositive());

            // equatorial horizontal paralax
            // 39.1
            this.parallax = GPMath.arcsinDeg(GPMath.sinDeg(8.794 / 3600) / (this.distanceFromEarth / GPAstroEngine.AU));

            // geocentric hour angle of the body
            h = apparent_sidereal_time - obs.GetLongitudeWestPositive() - right_ascession;


            // 39.2
            delta_alpha = GPMath.arctanDeg(
                (-rho_cos * GPMath.sinDeg(this.parallax) * GPMath.sinDeg(h)) /
                (GPMath.cosDeg(this.declination) - rho_cos * GPMath.sinDeg(this.parallax) * GPMath.cosDeg(h)));

            this.right_ascession += delta_alpha;
            this.declination      = GPMath.arctanDeg(
                ((GPMath.sinDeg(this.declination) - rho_sin * GPMath.sinDeg(this.parallax)) * GPMath.cosDeg(delta_alpha)) /
                (GPMath.cosDeg(this.declination) - rho_cos * GPMath.sinDeg(this.parallax) * GPMath.cosDeg(h)));
        }
Beispiel #3
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 #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
        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 #6
0
        protected double calculatePosition()
        {
            pMoon.MoonCalc(pJulianDate);
            pLastSunLongitude = GPSun.GetSunLongitude(pJulianDate);
            double l1 = GPMath.putIn360(pMoon.longitude_deg - pLastSunLongitude - opositeLongitude);

            return(GPMath.putIn180(l1));
        }
Beispiel #7
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 - GPAyanamsa.GetAyanamsa(pJulianDate));

            return(3 * l1 / 40.0);
        }
Beispiel #8
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 #9
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);
        }
Beispiel #10
0
 // tithi at sunset
 public int getTithiAtSunset()
 {
     if (p_tithi_sunset < 0)
     {
         GPCelestialBodyCoordinates moonCoord = GPAstroEngine.moon_coordinate(sun.set.getJulianGreenwichTime());
         double d = GPMath.putIn360(moonCoord.eclipticalLongitude - sun.longitude_set_deg - 180) / 12.0;
         p_tithi_sunset = Convert.ToInt32(Math.Floor(d));
     }
     return(p_tithi_sunset);
 }
Beispiel #11
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 #12
0
        public void calculateCoordinatesMethodM(double julian)
        {
            double DG  = GPMath.rads;
            double RAD = 180 / GPMath.pi;

            double t  = (julian - 2451545.0) / 36525;
            double t2 = t * t;
            double t3 = t2 * t;
            double t4 = t2 * t2;

            // mean ecliptic longitude of the sun
            double L0 = 280.4664567 + 36000.76982779 * t + 0.0003032028 * t2 + t3 / 49931000;

            // mean anomaly of the sun
            double M = 357.5291 + 35999.05030 * t - 0.0001559 * t2 - 0.00000048 * t3;

            L0             = GPMath.putIn360(L0);
            M              = GPMath.putIn360(M);
            sunMeanAnomaly = M;

            double C = (1.9146 - 0.004817 * t - 0.000014 * t2) * GPMath.sinDeg(M)
                       + (0.019993 - 0.000101 * t) * GPMath.sinDeg(2 * M)
                       + 0.00029 * GPMath.sinDeg(3 * M);

            sunEquationCenter = C;

            // ecliptic longitude of the sun
            //double els = 0;
            eclipticalLongitude = GPMath.putIn360(L0 + C);

            double e           = 0.016708617 - 0.000042037 * t - 0.0000001236 * t2;
            double trueAnomaly = M + C;


//            double epsilon;
//            double deltaPhi;

//            GPAstroEngine.calc_epsilon_phi(julianDay, out deltaPhi, out epsilon);
//            = 23.4391 - 0.013 * t - t2/6101694;
            double omega    = 125.04 - 1934.136 * t;
            double lambda   = eclipticalLongitude - 0.00569 - 0.00478 * GPMath.sinDeg(omega);
            double epsilon0 = 23.4392911 - 0.01300416 * t - 1.638e-7 * t2;
            double epsilon1 = epsilon0 + 0.00256 * GPMath.cosDeg(omega);

            // right ascension of the sun
            this.rightAscession = RAD * Math.Atan2(GPMath.cosDeg(epsilon1) * GPMath.sinDeg(lambda), GPMath.cosDeg(lambda));
            this.rightAscession = GPMath.putIn360(rightAscession);

            // declination of the sun
            this.declination = GPMath.arcsinDeg(GPMath.sinDeg(epsilon1) * GPMath.sinDeg(lambda));

            // equation of time
            equationOfTime = GPAstroEngine.getEquationOfTime(julian, this.rightAscession);
        }
Beispiel #13
0
        public void DynamicToFK5(ref double longitude, ref double latitude)
        {
            double lprime, t;
            double delta_l, delta_b;

            t         = 10 * Tau();
            lprime    = longitude + GPMath.deg2rad(-1.397 - 0.00031 * t) * t;
            delta_l   = -GPMath.deg2rad(0.09033 / 3600) + GPMath.deg2rad(0.03916 / 3600) * (Math.Cos(lprime) + Math.Sin(lprime)) * Math.Tan(latitude);
            delta_b   = GPMath.deg2rad(0.03916 / 3600) * (Math.Cos(lprime) - Math.Sin(lprime));
            longitude = longitude + delta_l;
            latitude  = latitude + delta_b;
        }
Beispiel #14
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 #15
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)));
        }
        /// <summary>
        /// Calculates sidereal time at Greenwich.
        /// Based on Chapter 11 of Astronomical Algorithms.
        /// </summary>
        /// <param name="date">Julian Ephemeris Day</param>
        /// <returns>Sidereal time in degrees.</returns>
        public void SetSiderealTime(double date)
        {
            double t;

            //date = 2446896.30625;
            //jd = date;
            t = (date - GPAstroEngine.J2000) / 36525.0;
            GPAstroEngine.calc_epsilon_phi(date, out delta_phi, out epsilon);

            // 11.2
            mean_sidereal_time = GPMath.putIn360(280.46061837 + 360.98564736629 * (date - GPAstroEngine.J2000) +
                                                 t * t * (0.000387933 - t / 38710000));

            apparent_sidereal_time = GPMath.putIn360(mean_sidereal_time + delta_phi * GPMath.cosDeg(epsilon));
        }
Beispiel #17
0
        private void calculateRiseSetMethodM(double D, GPLocationProvider ed)
        {
            GPLocation obs = ed.getLocation(D);
            double     a1, a2, a3;
            double     d1, d2, d3;
            double     siderealTime = GPAstroEngine.GetSiderealTime(D);
            double     h0           = -0.833333;

            calculateCoordinatesMethodM(D - 1);
            a1 = rightAscession;
            d1 = declination;
            calculateCoordinatesMethodM(D);
            a2 = rightAscession;
            d2 = declination;
            calculateCoordinatesMethodM(D + 1);
            a3 = rightAscession;
            d3 = declination;
            double longitude = -ed.GetLongitudeEastPositive();
            double latitude  = ed.GetLatitudeNorthPositive();
            double cosH0     = (GPMath.sinDeg(h0) - GPMath.sinDeg(latitude) * GPMath.sinDeg(d2))
                               / (GPMath.cosDeg(latitude) * GPMath.cosDeg(d2));
            double H0 = GPMath.arccosDeg(cosH0);

            H0 = GPMath.putIn180(H0);

            double m0     = (a2 + longitude - siderealTime) / 360;
            double m1     = m0 - H0 / 360;
            double m2     = m0 + H0 / 360;
            double deltaM = 0;

            deltaM = getCorrection(D, a1, a2, a3, d1, d2, d3, siderealTime, h0, longitude, latitude, m0, true);
            m0    += deltaM;
            deltaM = getCorrection(D, a1, a2, a3, d1, d2, d3, siderealTime, h0, longitude, latitude, m1, false);
            m1    += deltaM;
            deltaM = getCorrection(D, a1, a2, a3, d1, d2, d3, siderealTime, h0, longitude, latitude, m2, false);
            m2    += deltaM;

            julianDayRise = julianDay + m1;
            julianDayNoon = julianDay + m0;
            julianDaySet  = julianDay + m2;

            sunrise_deg = GPMath.putIn360(m1 * 360);
            noon_deg    = GPMath.putIn360(m0 * 360);
            sunset_deg  = GPMath.putIn360(m2 * 360);
        }
Beispiel #18
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);
        }
Beispiel #19
0
        private static double getCorrection(double D, double a1, double a2, double a3, double d1, double d2, double d3, double siderealTime, double h0, double longitude, double latitude, double m0, bool transit)
        {
            double deltaM = 0;
            double PHI    = siderealTime + 360.985647 * m0;
            double n      = m0 + GPDynamicTime.GetDeltaT(D) / 86400;

            double alpha = GPAstroEngine.interpolation(a1, a2, a3, n);
            double delta = GPAstroEngine.interpolation(d1, d2, d3, n);

            double H = GPMath.putIn180(PHI - longitude - alpha);
            double h = 0;

            if (transit)
            {
                deltaM = -H / 360;
            }
            else
            {
                double sinH = GPMath.sinDeg(latitude) * GPMath.sinDeg(delta) + GPMath.cosDeg(latitude) * GPMath.cosDeg(delta) * GPMath.cosDeg(H);
                h      = GPMath.arcsinDeg(sinH);
                deltaM = (h - h0) / (360 * GPMath.cosDeg(delta) * GPMath.cosDeg(latitude) * GPMath.sinDeg(H));
            }
            return(deltaM);
        }
Beispiel #20
0
        public double getNaksatraDouble(double day)
        {
            double d = GPMath.putIn360(coord.eclipticalLongitude - GPAyanamsa.GetAyanamsa(day));

            return((d * 3.0) / 40.0);
        }
Beispiel #21
0
 public double getTithiDouble()
 {
     return(GPMath.putIn360(coordMoon.eclipticalLongitude - coordSun.eclipticalLongitude - 180) / 30);
 }
Beispiel #22
0
        public double getYogaDouble(double day)
        {
            double d = GPMath.putIn360(coordMoon.eclipticalLongitude + coordSun.eclipticalLongitude - 2 * GPAyanamsa.GetAyanamsa(day));

            return((d * 3.0) / 40.0);
        }
Beispiel #23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg">Julian Ephemeris (Dynamical) Time</param>
        /// <returns></returns>
        public override double getDoubleValue(double arg)
        {
            coordMoon = GPAstroEngine.moon_coordinate(arg);
            coordSun  = GPAstroEngine.sun_coordinate(arg);

            switch (valueType)
            {
            case ValueType.Longitude:
                return(GPMath.putIn180(coordMoon.eclipticalLongitude - coordSun.eclipticalLongitude));

            case ValueType.Latitude:
                return(GPMath.putIn180(coordMoon.eclipticalLatitude - coordSun.eclipticalLatitude));

            case ValueType.Azimuth:
                if (obs != null)
                {
                    coordMoon.makeTopocentric(obs);
                    GPAstroEngine.calcHorizontal(coordMoon, obs);

                    GPAstroEngine.calcHorizontal(coordSun, obs);
                    return(GPMath.putIn180(coordMoon.azimuth - coordSun.azimuth));
                }
                break;

            case ValueType.Elevation:
                if (obs != null)
                {
                    coordMoon.makeTopocentric(obs);
                    GPAstroEngine.calcHorizontal(coordMoon, obs);
                    GPAstroEngine.calcHorizontal(coordSun, obs);
                    return(GPMath.putIn180(coordMoon.elevation - coordSun.elevation));
                }
                break;

            case ValueType.DeclinationTopo:
                if (obs != null)
                {
                    coordMoon.makeTopocentric(obs);
                    return(GPMath.putIn180(coordMoon.declination - coordSun.declination));
                }
                break;

            case ValueType.RightAscessionTopo:
                if (obs != null)
                {
                    coordMoon.makeTopocentric(obs);
                    return(GPMath.putIn180(coordMoon.right_ascession - coordSun.right_ascession));
                }
                break;

            case ValueType.Declination:
                return(GPMath.putIn180(coordMoon.declination - coordSun.declination));

            case ValueType.TithiDistance:
            {
                double tithi = getTithiDouble();
                tithi = 0.51 - Math.Abs(tithi - Math.Floor(tithi) - 0.5);
                return(tithi);
            }

            case ValueType.YogaDistance:
            {
                double yoga = getYogaDouble(arg);
                yoga = 0.51 - Math.Abs(yoga - Math.Floor(yoga) - 0.5);
                return(yoga);
            }

            case ValueType.RightAscession:
                return(GPMath.putIn180(coordMoon.right_ascession - coordSun.right_ascession));

            case ValueType.RightAscessionAbs:
                return(Math.Abs(GPMath.putIn180(coordMoon.right_ascession - coordSun.right_ascession)));

            case ValueType.ApparentSiderealTime:
                return(coordMoon.apparent_sidereal_time);

            case ValueType.MeanSiderealTime:
                return(coordMoon.mean_sidereal_time);

            case ValueType.DynamicTime:
                return(coordMoon.getDynamicTime());

            case ValueType.Nutation:
                return(coordMoon.getNutation());

            case ValueType.Obliquity:
                return(coordMoon.getObliquity());

            case ValueType.AzimuthElevationDistance:
                if (obs != null)
                {
                    coordMoon.makeTopocentric(obs);
                    GPAstroEngine.calcHorizontal(coordMoon, obs);
                    GPAstroEngine.calcHorizontal(coordSun, obs);
                    return(GPMath.arcDistanceDeg(coordMoon.azimuth, coordMoon.elevation, coordSun.azimuth, coordSun.elevation));
                }
                break;

            case ValueType.RigthAscessionDeclinationDistance:
                return(GPMath.arcDistanceDeg(coordMoon.right_ascession, coordMoon.declination, coordSun.right_ascession, coordSun.declination));

            case ValueType.RigthAscessionDeclinationOpositeDistance:
                return(GPMath.arcDistanceDeg(180 + coordMoon.right_ascession, -coordMoon.declination, coordSun.right_ascession, coordSun.declination));

            case ValueType.Tithi:
                return(getTithiDouble());

            case ValueType.Yoga:
                return(getYogaDouble(arg));

            default:
                break;
            }

            return(0);
        }
Beispiel #24
0
 public int GetSunriseRasi(double Ayanamsa)
 {
     return(Convert.ToInt32(Math.Floor(GPMath.putIn360(eclipticalLongitude - Ayanamsa) / 30.0)));
 }
Beispiel #25
0
 public static int GetRasi(double SunLongitude, double Ayanamsa)
 {
     return(Convert.ToInt32(Math.Floor(GPMath.putIn360(SunLongitude - Ayanamsa) / 30.0)));
 }
Beispiel #26
0
        public override double calculatePosition()
        {
            double prev = GPMath.putIn360(GPSun.GetSunLongitude(pJulianDate) - GPAyanamsa.GetAyanamsa(pJulianDate));

            return(prev / 30.0);
        }
Beispiel #27
0
        public double getSankrantiDouble(double jd)
        {
            double ld = GPMath.putIn360(coord.eclipticalLongitude - GPAyanamsa.GetAyanamsa(jd));

            return(ld / 30.0);
        }
 /// <summary>
 /// Calculates visibility angle of celectial body, for given physical radius.
 /// </summary>
 /// <param name="physicalRadius">Radius in kilometers</param>
 /// <returns></returns>
 public double getVisibleAngle(double physicalRadius)
 {
     return(GPMath.rad2deg(Math.Asin(physicalRadius / distanceFromEarth)));
 }
Beispiel #29
0
        public void calculateAppearanceDayData(GPLocationProvider aLocation, GPGregorianTime aEvente)
        {
            //MOONDATA moon;
            //SUNDATA sun;
            location = aLocation;
            evente   = new GPGregorianTime(aEvente);
            double          dd;
            GPAstroData     d     = details;
            GPGregorianTime vc    = evente;
            GPGregorianTime vcsun = evente;

            b_adhika = false;

            d.calculateDayData(aEvente, aLocation);
            //d.nTithi = GetPrevTithiStart(m_earth, vc, dprev);
            //GetNextTithiStart(m_earth, vc, dnext);
            //vcsun.setDayHours(vcsun.getDayHours() - vcsun.getTimeZoneOffsetHours() / 24.0);
            vcsun.normalizeValues();
            d.sun.calculateCoordinatesMethodC(vcsun, -1);
            d.moon.MoonCalc(vcsun.getJulianGreenwichTime());
            d.msDistance = GPMath.putIn360(d.moon.longitude_deg - d.sun.eclipticalLongitude - 180.0);
            d.msAyanamsa = GPAyanamsa.GetAyanamsa(vc.getJulianGreenwichTime());

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


            // naksatra
            dd                = GPMath.putIn360(d.moon.longitude_deg - d.msAyanamsa);
            dd                = (dd * 3.0) / 40.0;
            d.nNaksatra       = Convert.ToInt32(Math.Floor(dd));
            d.nNaksatraElapse = GPMath.frac(dd) * 100.0;
            d.nMasa           = d.determineMasa(vc, out d.nGaurabdaYear);
            d.nMoonRasi       = GPEngine.GetRasi(d.moon.longitude_deg, d.msAyanamsa);
            d.nSunRasi        = GPEngine.GetRasi(d.sun.eclipticalLongitude, d.msAyanamsa);

            if (d.nMasa == GPMasa.ADHIKA_MASA)
            {
                d.nMasa  = GPEngine.GetRasi(d.sun.eclipticalLongitude, d.msAyanamsa);
                b_adhika = true;
            }
            string dstApplicable = "";

            //List<string> gstr = GPStrings.getSharedStrings().gstr;
            output.Add(new GPStringPair(GPStrings.getString(25), "", true));
            output.Add(new GPStringPair(GPStrings.getString(7), vc.ToString()));
            output.Add(new GPStringPair(GPStrings.getString(8), vc.getShortTimeString(true, ref dstApplicable)));
            output.Add(new GPStringPair(GPStrings.getString(9), vc.getLocation().getFullName()));
            //output.Add(new GPStringPair(gstr[10], vc.getLocation().getLatitudeString()));
            //output.Add(new GPStringPair(gstr[11], vc.getLocation().getLongitudeString()));
            //output.Add(new GPStringPair(gstr[12], vc.getLocation().getTimeZoneName()));
            //output.Add(new GPStringPair(gstr[1001], dstApplicable));
            output.Add(new GPStringPair(GPStrings.getString(13), GPTithi.getName(d.nTithi)));
            output.Add(new GPStringPair(GPStrings.getString(14), string.Format("{0:0.###} %", d.nTithiElapse)));
            output.Add(new GPStringPair(GPStrings.getString(15), GPNaksatra.getName(d.nNaksatra)));
            output.Add(new GPStringPair(GPStrings.getString(16), string.Format("{0:0.###} % ({1})", d.nNaksatraElapse, GPStrings.getString(811 + Convert.ToInt32(d.nNaksatraElapse / 25.0)))));
            output.Add(new GPStringPair(GPStrings.getString(991), GPSankranti.getName(d.nMoonRasi)));
            output.Add(new GPStringPair(GPStrings.getString(992), GPSankranti.getName(d.nSunRasi)));
            output.Add(new GPStringPair(GPStrings.getString(20), GPPaksa.getName(d.nPaksa)));
            if (b_adhika == true)
            {
                output.Add(new GPStringPair(GPStrings.getString(22), string.Format("{0} {1}", GPMasa.GetName(d.nMasa), GPStrings.getString(21))));
            }
            else
            {
                output.Add(new GPStringPair(GPStrings.getString(22), GPMasa.GetName(d.nMasa)));
            }
            output.Add(new GPStringPair(GPStrings.getString(23), d.nGaurabdaYear.ToString()));

            if (GPDisplays.AppDay.childNameSuggestions())
            {
                output.Add(new GPStringPair());
                output.Add(new GPStringPair(GPStrings.getString(17), "", true));
                output.Add(new GPStringPair());
                output.Add(new GPStringPair(GPStrings.getString(18), string.Format("{0}...", GPAppHelper.GetNaksatraChildSylable(d.nNaksatra, Convert.ToInt32(d.nNaksatraElapse / 25.0)))));
                output.Add(new GPStringPair(GPStrings.getString(19), string.Format("{0}...", GPAppHelper.GetRasiChildSylable(d.nMoonRasi))));
            }

            vc.Today();
            GPVedicTime     va = new GPVedicTime();
            GPGregorianTime vctemp;

            va.tithi = d.nTithi;
            va.masa  = d.nMasa;
            va.gyear = GPGaurabdaYear.getGaurabdaYear(vc, location);
            if (va.gyear < d.nGaurabdaYear)
            {
                va.gyear = d.nGaurabdaYear;
            }


            int countC = GPUserDefaults.IntForKey("appday.celebs", 3);

            if (countC > 0)
            {
                output.Add(new GPStringPair());
                output.Add(new GPStringPair(GPStrings.getString(24), "", true));
                output.Add(new GPStringPair());
            }

            int m = 0;

            for (int i = 0; i < 6; i++)
            {
                GPEngine.VATIMEtoVCTIME(va, out vctemp, location);
                if (va.gyear > d.nGaurabdaYear)
                {
                    if (m < countC)
                    {
                        output.Add(new GPStringPair(string.Format("{0} {1}", GPStrings.getString(994), va.gyear), vctemp.ToString()));
                        m++;
                    }
                }
                va.gyear++;
            }
        }
Beispiel #30
0
 public int GetRasi(double ayanamsa)
 {
     return(Convert.ToInt32(Math.Floor(GPMath.putIn360(longitude_deg - ayanamsa) / 30.0)));
 }