Example #1
0
        /// <summary>
        /// Calculates all celestial data. Coordinates will notify as changes occur
        /// </summary>
        /// <param name="lat">Decimal format latitude</param>
        /// <param name="longi">Decimal format longitude</param>
        /// <param name="date">Geographic DateTime</param>
        /// <param name="el">EagerLoading Info for Auto-Calculations</param>
        internal void CalculateCelestialTime(double lat, double longi, DateTime date, EagerLoad el)
        {
            date = new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, DateTimeKind.Utc);


            SunCalc.CalculateSunTime(lat, longi, date, this, el);


            if (el.Extensions.Lunar_Cycle)
            {
                MoonCalc.GetMoonTimes(date, lat, longi, this);
                MoonCalc.GetMoonDistance(date, this);


                perigee = MoonCalc.GetPerigeeEvents(date);
                apogee  = MoonCalc.GetApogeeEvents(date);
            }
            MoonCalc.GetMoonIllumination(date, this, lat, longi, el);

            if (el.Extensions.Zodiac)
            {
                SunCalc.CalculateZodiacSign(date, this);
                MoonCalc.GetMoonSign(date, this);
            }

            Calculate_Celestial_IsUp_Booleans(date, this);
        }
        /// <summary>
        /// Calculates all celestial data. Coordinates will notify as changes occur
        /// </summary>
        /// <param name="lat">Decimal format latitude</param>
        /// <param name="longi">Decimal format longitude</param>
        /// <param name="date">Geographic DateTime</param>
        /// <param name="el">EagerLoading Info for Auto-Calculations</param>
        /// <param name="offset">UTC offset in hours</param>
        internal void CalculateCelestialTime(double lat, double longi, DateTime date, EagerLoad el, double offset)
        {
            if (offset < -12 || offset > 12)
            {
                throw new ArgumentOutOfRangeException("Time offsets cannot be greater than 12 or less than -12.");
            }

            date = new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, DateTimeKind.Utc);

            if (el.Extensions.Solar_Cycle || el.Extensions.Solar_Eclipse)
            {
                SunCalc.CalculateSunTime(lat, longi, date, this, el, offset);
            }
            if (el.Extensions.Lunar_Cycle)
            {
                MoonCalc.GetMoonTimes(date, lat, longi, this, offset);
                MoonCalc.GetMoonDistance(date, this, offset);


                perigee = MoonCalc.GetPerigeeEvents(date);
                apogee  = MoonCalc.GetApogeeEvents(date);

                //Shift perigee / apogee is working outside UTC
                if (offset != 0)
                {
                    perigee.ConvertTo_Local_Time(offset);
                    apogee.ConvertTo_Local_Time(offset);
                }
            }

            if (el.Extensions.Lunar_Cycle || el.Extensions.Zodiac || el.Extensions.Lunar_Eclipse)
            {
                MoonCalc.GetMoonIllumination(date, this, lat, longi, el, offset);
            }

            if (el.Extensions.Zodiac)
            {
                SunCalc.CalculateZodiacSign(date, this);
                MoonCalc.GetMoonSign(date, this);
            }

            if (el.Extensions.Lunar_Cycle || el.Extensions.Solar_Cycle)
            {
                Calculate_Celestial_IsUp_Booleans(date, this);
            }

            //Shift eclipses if eagerloaded and offset is not 0
            if (el.Extensions.Lunar_Eclipse && offset != 0)
            {
                lunarEclipse.ConvertTo_LocalTime(offset);
            }
            if (el.Extensions.Solar_Eclipse && offset != 0)
            {
                solarEclipse.ConvertTo_LocalTime(offset);
            }
        }
Example #3
0
        /// <summary>
        /// Calculate moon data based on latitude, longitude and UTC date at the location.
        /// </summary>
        /// <param name="lat">latitude</param>
        /// <param name="longi">longitude</param>
        /// <param name="date">DateTime</param>
        /// <returns>Celestial (Partially Populated)</returns>
        /// <example>
        /// The following example demonstrates how to create a partially populated Celestial object
        /// that only calculates lunar data using static functions.
        /// <code>
        /// //Get Celestial data at N 39, W 72 on 19-Mar-2019 10:10:12 UTC
        /// Celestial cel = Celestial.CalculateMoonData(39, -72, new DateTime(2019, 3, 19, 10, 10, 12));
        ///
        /// Console.WriteLine(cel.MoonRise); //3/19/2019 9:27:27 PM
        /// </code>
        /// </example>
        public static Celestial CalculateMoonData(double lat, double longi, DateTime date)
        {
            date = new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, DateTimeKind.Utc);

            Celestial c = new Celestial(false);

            MoonCalc.GetMoonTimes(date, lat, longi, c);
            MoonCalc.GetMoonDistance(date, c);
            MoonCalc.GetMoonSign(date, c);
            MoonCalc.GetMoonIllumination(date, c, lat, longi, new EagerLoad());

            c.perigee = MoonCalc.GetPerigeeEvents(date);
            c.apogee  = MoonCalc.GetApogeeEvents(date);

            return(c);
        }
Example #4
0
        /// <summary>
        /// Calculates all celestial data. Coordinates will notify as changes occur
        /// </summary>
        /// <param name="lat">Decimal format latitude</param>
        /// <param name="longi">Decimal format longitude</param>
        /// <param name="date">Geographic DateTime</param>
        internal void CalculateCelestialTime(double lat, double longi, DateTime date)
        {
            date = new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, DateTimeKind.Utc);
            SunCalc.CalculateSunTime(lat, longi, date, this);
            MoonCalc.GetMoonTimes(date, lat, longi, this);
            MoonCalc.GetMoonDistance(date, this);

            SunCalc.CalculateZodiacSign(date, this);
            MoonCalc.GetMoonSign(date, this);

            MoonCalc.GetMoonIllumination(date, this, lat, longi);


            this.Perigee = MoonCalc.GetPerigeeEvents(date);
            this.Apogee  = MoonCalc.GetApogeeEvents(date);
        }
Example #5
0
        /// <summary>
        /// Calculate celestial data based on lat/long and date.
        /// </summary>
        /// <param name="lat">Decimal format latitude</param>
        /// <param name="longi">Decimal format longitude</param>
        /// <param name="date">Geographic DateTime</param>
        /// <returns>Fully populated Celestial object</returns>
        public static Celestial CalculateCelestialTimes(double lat, double longi, DateTime date)
        {
            date = new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, DateTimeKind.Utc);

            Celestial c = new Celestial(false);

            SunCalc.CalculateSunTime(lat, longi, date, c);
            MoonCalc.GetMoonTimes(date, lat, longi, c);
            MoonCalc.GetMoonDistance(date, c);
            SunCalc.CalculateZodiacSign(date, c);
            MoonCalc.GetMoonSign(date, c);
            MoonCalc.GetMoonIllumination(date, c, lat, longi);

            c.Perigee = MoonCalc.GetPerigeeEvents(date);
            c.Apogee  = MoonCalc.GetApogeeEvents(date);

            return(c);
        }
Example #6
0
 /// <summary>
 /// Returns Apogee object containing last and next apogees based on the specified UTC date.
 /// </summary>
 /// <param name="d">DateTime</param>
 /// <returns>Apogee</returns>
 /// <example>
 /// The following example gets the last and next lunar apogees from the specified date
 /// and display's their DateTime and Distance.
 /// <code>
 /// Apogee apogee = Celestial.GetApogees(new DateTime(2019,3,1));
 ///
 /// Console.WriteLine(apogee.LastApogee.Date + " " + apogee.LastApogee.Distance.Kilometers); //2/5/2019 9:27:28 AM 406551.526207563
 /// Console.WriteLine(apogee.NextApogee.Date + " " + apogee.NextApogee.Distance.Kilometers); //3/4/2019 11:26:35 AM 406387.933655865
 /// </code>
 /// </example>
 public static Apogee GetApogees(DateTime d)
 {
     return(MoonCalc.GetApogeeEvents(d));
 }