コード例 #1
0
        public void FindInstantBesselianElements()
        {
            // 11 Aug 1999, 11:00:00 TDT
            // Besselian elements are taken from
            // https://eclipse.gsfc.nasa.gov/SEsearch/SEdata.php?Ecl=+19990811
            // Sun and Moon geocentric positions are taken
            // from NASA horizons tool
            // https://ssd.jpl.nasa.gov/horizons.cgi

            var position = new SunMoonPosition()
            {
                JulianDay    = 2451401.958333333,
                Sun          = new CrdsEquatorial(new HMS("09h 23m 11.27s"), new DMS("+15* 19' 30.1''")),
                Moon         = new CrdsEquatorial(new HMS("09h 23m 30.71s"), new DMS("+15* 48' 50.3''")),
                DistanceSun  = 1.5162934697E+08 / 6371.0,
                DistanceMoon = 3.7330565613E+05 / 6371.0
            };

            var elements = SolarEclipses.BesselianElements(position);

            Assert.AreEqual(15.32734, elements.D, 1e-2);
            Assert.AreEqual(343.68741, elements.Mu, 1e-1);
            Assert.AreEqual(0.070042, elements.X, 1e-2);
            Assert.AreEqual(0.502841, elements.Y, 1e-2);
            Assert.AreEqual(0.542469, elements.L1, 1e-2);
            Assert.AreEqual(-0.003650, elements.L2, 1e-2);
        }
コード例 #2
0
    void ResetTime(DateTime dateTime)
    {
        var tz = mapOrigin.TimeZone;

        var utcMidnight = TimeZoneInfo.ConvertTimeToUtc(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, 0, 0, 0, DateTimeKind.Unspecified), tz);

        jday = SunMoonPosition.GetJulianDayFromGregorianDateTime(utcMidnight);

        SunMoonPosition.GetSunRiseSet(tz, dateTime, gpsLocation.Longitude, gpsLocation.Latitude, out sunRiseBegin, out sunRiseEnd, out sunSetBegin, out sunSetEnd);

        currentTimeOfDay      = (float)dateTime.TimeOfDay.TotalHours;
        currentTimeOfDayCycle = TimeOfDayCycleTypes.Freeze;
    }
コード例 #3
0
    private void ResetTime(DateTime dateTime)
    {
        var tz = MapOrigin.TimeZone;

        var utcMidnight = TimeZoneInfo.ConvertTimeToUtc(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, 0, 0, 0, DateTimeKind.Unspecified), tz);

        JDay = SunMoonPosition.GetJulianDayFromGregorianDateTime(utcMidnight);

        SunMoonPosition.GetSunRiseSet(tz, dateTime, GPSLocation.Longitude, GPSLocation.Latitude, out SunRiseBegin, out SunRiseEnd, out SunSetBegin, out SunSetEnd);

        CurrentDateTime       = dateTime;
        CurrentTimeOfDay      = (float)dateTime.TimeOfDay.TotalHours;
        CurrentTimeOfDayCycle = TimeOfDayCycleTypes.Freeze;

        UpdateDistributedState();
    }
コード例 #4
0
        /// <summary>
        /// Calculates solar and lunar positions at five uniformly spaced times
        /// over a specified period centered at t0, where t0 is an integer hour of day
        /// nearest to the specified time instant of eclipse maximum.
        /// </summary>
        /// <param name="jdMaximum">Instant of eclipse maximum.</param>
        /// <param name="period">Period, in hours.</param>
        /// <returns></returns>
        private SunMoonPosition[] GetSunMoonPositions(double jdMaximum, double period)
        {
            // found t0 (nearest integer hour closest to the eclipse maximum)
            double t0;
            Date   d = new Date(jdMaximum);

            if (d.Minute < 30)
            {
                t0 = jdMaximum - new TimeSpan(0, d.Minute, d.Second).TotalDays;
            }
            else
            {
                t0 = jdMaximum - new TimeSpan(0, d.Minute, d.Second).TotalDays + TimeSpan.FromHours(1).TotalDays;
            }

            // The Besselian elements are derived from a least-squares fit to elements
            // calculated at five uniformly spaced times over a period centered at t0.
            SunMoonPosition[] pos = new SunMoonPosition[5];

            double dt   = TimeSpan.FromHours(period / 2).TotalDays;
            double step = TimeSpan.FromHours(period / 4).TotalDays;

            string[] ephemerides = new[] { "Equatorial0.Alpha", "Equatorial0.Delta", "Distance" };

            var sunEphem  = sky.GetEphemerides(sun, t0 - dt, t0 + dt + 1e-6, step, ephemerides);
            var moonEphem = sky.GetEphemerides(moon, t0 - dt, t0 + dt + 1e-6, step, ephemerides);

            // astronomical unit, in km
            const double AU = 149597870;

            // earth radius, in km
            const double EARTH_RADIUS = 6371;

            for (int i = 0; i < 5; i++)
            {
                pos[i] = new SunMoonPosition()
                {
                    JulianDay    = t0 + step * (i - 2),
                    Sun          = new CrdsEquatorial(sunEphem[i].GetValue <double>("Equatorial0.Alpha"), sunEphem[i].GetValue <double>("Equatorial0.Delta")),
                    Moon         = new CrdsEquatorial(moonEphem[i].GetValue <double>("Equatorial0.Alpha"), moonEphem[i].GetValue <double>("Equatorial0.Delta")),
                    DistanceSun  = sunEphem[i].GetValue <double>("Distance") * AU / EARTH_RADIUS,
                    DistanceMoon = moonEphem[i].GetValue <double>("Distance") / EARTH_RADIUS
                };
            }

            return(pos);
        }
コード例 #5
0
 private void UpdateSunPosition()
 {
     sun.transform.rotation = SunMoonPosition.GetSunPosition(jday + currentTimeOfDay / 24f, gpsLocation.Longitude, gpsLocation.Latitude);
 }
コード例 #6
0
 private void UpdateMoonPosition()
 {
     Moon.transform.localRotation = SunMoonPosition.GetMoonPosition(JDay + CurrentTimeOfDay / 24f, GPSLocation.Longitude, GPSLocation.Latitude);
 }