Example #1
0
        /// <summary>
        /// Convert elevation angle to zone time.
        /// </summary>
        /// <param name="e">Equator coordinates.</param>
        /// <param name="angle">Elevation angle.</param>
        /// <param name="latitude">Local latitude.</param>
        /// <param name="longitude">Local longitude.</param>
        /// <param name="date">Date.</param>
        /// <param name="localTimeZone">Local time zone.</param>
        /// <returns>Zone time in degree.</returns>
        public static double[] ElevationAngle2Time(Equator e, double angle, double latitude, double longitude, DateTime date, TimeZoneInfo localTimeZone)
        {
            double ra  = e.RA;
            double dec = e.Dec;

            double sinH = Math.Sin(angle * (Math.PI / 180.0));
            double cosT = (sinH - Math.Sin(latitude * Math.PI / 180.0) * Math.Sin(dec * Math.PI / 180.0)) / (Math.Cos(latitude * Math.PI / 180.0) * Math.Cos(dec * Math.PI / 180.0));

            if (Math.Abs(cosT) > 1)
            {
                return(new double[] { 0, 0 });
            }
            double T = Math.Acos(cosT) * 180.0 / Math.PI;

            double t1 = 360 - T;
            double t2 = T;

            double localSiderealTime1 = t1 + ra;
            double zoneTime1          = SiderealTime.SiderealTime2ZoneTime(localSiderealTime1, date, localTimeZone, longitude);

            double localSiderealTime2 = t2 + ra;
            double zoneTime2          = SiderealTime.SiderealTime2ZoneTime(localSiderealTime2, date, localTimeZone, longitude);

            return(new double[] { zoneTime1, zoneTime2 });
        }
Example #2
0
        /// <summary>
        /// Calculate local hour angle.
        /// </summary>
        /// <param name="time">Local time.</param>
        /// <param name="RA">Right ascension.</param>
        /// <param name="longitude">Local longitude.</param>
        /// <returns>The hour angle.</returns>
        public static double GetHourAngle(DateTime time, double RA, double longitude)
        {
            double ra = RA;
            double localSiderealTime = SiderealTime.LocalMeanSiderealTime(time, TimeZoneInfo.Local, longitude);

            double ha = localSiderealTime - ra;

            return(ha);
        }