Exemplo n.º 1
0
 public void MoonCalc(double jdate)
 {
     coord           = GPAstroEngine.moon_coordinate(jdate);
     radius          = coord.distanceFromEarth;
     longitude_deg   = coord.eclipticalLongitude;
     latitude_deg    = coord.eclipticalLatitude;
     declination     = coord.declination;
     right_ascession = coord.right_ascession;
 }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
0
        public static void TestMoonCoordinates()
        {
            GPObserver obs = new GPObserver();

            obs.setLatitudeNorthPositive(defLatitude).setLongitudeEastPositive(defLongitude).SetAltitude(0.2);
            GPJulianTime dp = new GPJulianTime();

            dp.setLocalJulianDay(2456710.500000);
            for (int k = 0; k < 26; k++)
            {
                //dp = MA.GPMeeusEngine.GetNextMoonEvent(dp, obs, out kind);
                GPCelestialBodyCoordinates crd = GPAstroEngine.moon_coordinate(dp.getGreenwichJulianEphemerisDay());
                //srt = MA.GPMeeusEngine.GetSiderealTime(dp.GetJulianDay(), out deltaphi, out epsilon);
                //crd = MA.GPMeeusEngine.moon_coordinate(2448724.5);
                crd.makeTopocentric(obs);
                GPAstroEngine.calcHorizontal(crd, obs);
                //Log("time {0}   deltaphi {1}  epsilon {2} sidereal {3}", dp, deltaphi, epsilon, srt/15);
                //Log("time {0}   altitude {1}  azimuth {2}", dp, crd.elevation, crd.azimuth);
                //Log("time {0}   ra {1}  dec {2}", dp, crd.right_ascession, crd.declination);
                Log("{0}", crd.azimuth);
                //                Log("next event = {0}, {1}, {2}\n", dp, kind, crd.elevation);
                dp.AddHours(1);
            }
        }
Exemplo n.º 4
0
        public override double getDoubleValue(double arg)
        {
            coord = GPAstroEngine.moon_coordinate(arg);

            switch (valueType)
            {
            case ValueType.Longitude:
                return(coord.eclipticalLongitude);

            case ValueType.Latitude:
                return(coord.eclipticalLatitude);

            case ValueType.Azimuth:
                if (obs != null)
                {
                    coord.makeTopocentric(obs);
                    GPAstroEngine.calcHorizontal(coord, obs);
                    return(coord.azimuth);
                }
                break;

            case ValueType.Elevation:
                if (obs != null)
                {
                    coord.makeTopocentric(obs);
                    GPAstroEngine.calcHorizontal(coord, obs);
                    return(coord.elevation);
                }
                break;

            case ValueType.DeclinationTopo:
                if (obs != null)
                {
                    coord.makeTopocentric(obs);
                    return(coord.declination);
                }
                break;

            case ValueType.RightAscessionTopo:
                if (obs != null)
                {
                    coord.makeTopocentric(obs);
                    return(coord.right_ascession);
                }
                break;

            case ValueType.Declination:
                return(coord.declination);

            case ValueType.RightAscession:
                return(coord.right_ascession);

            case ValueType.Distance:
                return(coord.distanceFromEarth);

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

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

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

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

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

            case ValueType.NaksatraDistance:
            {
                double naksatraReal = getNaksatraDouble(arg);
                naksatraReal = 0.51 - Math.Abs(naksatraReal - Math.Floor(naksatraReal) - 0.5);
                return(naksatraReal);
            }

            case ValueType.Naksatra:
                return(getNaksatraDouble(arg));

            default:
                break;
            }

            return(0);
        }
Exemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            GPLocation loc;

            content.findLocations("Bratislava");
            loc = content.getLocation(0);
            GPLocationProvider provider = new GPLocationProvider(loc);
            int nCount = 365;

            GPGregorianTime   startDateA = new GPGregorianTime(loc);
            GPCalendarResults calA       = new GPCalendarResults();
            GPCalendarResults calB       = new GPCalendarResults();

            calA.progressReport = this;
            calB.progressReport = this;

            if (startDateA != null)
            {
                GPSun.sunPosMethod = GPSun.SUNPOSMETHOD_CALCULATOR;
                calA.CalculateCalendar(startDateA, nCount);
                GPSun.sunPosMethod = GPSun.SUNPOSMETHOD_CALCULATOREX;
                calB.CalculateCalendar(startDateA, nCount);
            }
            GPSun.sunPosMethod = GPSun.SUNPOSMETHOD_CALCULATOR;

            StringBuilder sb = new StringBuilder();

            GPCalendarTwoLocResults cals = new GPCalendarTwoLocResults();

            cals.CalendarA = calA;
            cals.CalendarB = calB;

            FormaterHtml.WriteCompareCalendarHTML(cals, sb);

            string HtmlText = sb.ToString();

            webBrowser1.DocumentText = HtmlText;

            GPObserver obs = new GPObserver();

            obs = loc;

            GPStrings.pushRich(false);

            StringBuilder sba = new StringBuilder();
            GPJulianTime  sunRise, sunNoon, sunSet;

            for (int i = 0; i < calA.getCount(); i++)
            {
                GPCalendarDay cd  = calA.get(i);
                GPCalendarDay cd2 = calB.get(i);
                GPAstroEngine.CalculateTimeSun(cd.date, loc, out sunRise, out sunNoon, out sunSet);
                GPGregorianTime gt = new GPGregorianTime(loc);

                GPCelestialBodyCoordinates pos = GPAstroEngine.sun_coordinate(GPDynamicTime.getUniversalTimeFromDynamicTime(2457012.82313));
                GPAstroEngine.calcHorizontal(pos, loc);

                sunRise.setLocalTimezoneOffset(loc.getTimeZoneOffsetHours());
                sba.AppendFormat("{0}     {1}    {2}  \n", cd.date.ToString(),
                                 cd.getSunriseTime().getLongTimeString(),
                                 cd2.getSunriseTime().getLongTimeString());
                gt.setDate(1992, 10, 13);
                //cd.astrodata.sun.calculateCoordinatesMethodM(gt, 360/24.0);
            }

            GPStrings.popRich();

            richTextBox1.Text = sba.ToString();


            GPGregorianTime t1 = new GPGregorianTime(loc);

            t1.setDate(2015, 4, 4);

            double jd = t1.getJulianLocalNoon();

            sba.Clear();
            for (double d = 0.3; d < 1.0; d += 0.01)
            {
                double ml  = GPAstroEngine.moon_coordinate(jd + d).eclipticalLongitude;
                double sl1 = GPAstroEngine.sun_coordinate(jd + d).eclipticalLongitude;
                double sl2 = GPAstroEngine.sunLongitudeMethodM(jd + d);
                sba.AppendFormat("{0} : {1} {2} {3}\n", jd + d, ml, sl1, sl2);
            }
            richTextBox2.Text = sba.ToString();
        }
Exemplo n.º 6
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);
        }