Example #1
0
        public void EquatorialToHorizontal()
        {
            // Apparent equatorial coordinates of Venus
            var eq = new CrdsEquatorial(new HMS("23h 09m 16.641s"), new DMS("-6* 43' 11.61''"));

            // Geographical coordinates of US Naval Observatory at Washington, DC
            var geo = new CrdsGeographical(new DMS("+38* 55' 17''"), new DMS("+77* 03' 56''"));

            // Date of observation
            var jd = new Date(new DateTime(1987, 4, 10, 19, 21, 0, DateTimeKind.Utc)).ToJulianDay();

            // Mean sidereal time at Greenwich
            var theta0 = Date.MeanSiderealTime(jd);

            Assert.AreEqual(new HMS("8h 34m 57.0896s"), new HMS(theta0));

            // Nutation elements
            var nutation = Nutation.NutationElements(jd);

            // True obliquity
            var epsilon = Date.TrueObliquity(jd, nutation.deltaEpsilon);

            // Apparent sidereal time at Greenwich
            theta0 = Date.ApparentSiderealTime(jd, nutation.deltaPsi, epsilon);
            Assert.AreEqual(new HMS("8h 34m 56.853s"), new HMS(theta0));

            // Expected local horizontal coordinates of Venus
            var hor = eq.ToHorizontal(geo, theta0);

            Assert.AreEqual(15.1249, hor.Altitude, 1e-4);
            Assert.AreEqual(68.0336, hor.Azimuth, 1e-4);
        }
Example #2
0
        public Sky()
        {
            // Ecliptic
            LineEcliptic.FromHorizontal = (h) =>
            {
                var eq = h.ToEquatorial(GeoLocation, LocalSiderealTime);
                var ec = eq.ToEcliptical(Epsilon);
                return(new GridPoint(ec.Lambda, ec.Beta));
            };
            LineEcliptic.ToHorizontal = (c) =>
            {
                var ec = new CrdsEcliptical(c.Longitude, c.Latitude);
                var eq = ec.ToEquatorial(Epsilon);
                return(eq.ToHorizontal(GeoLocation, LocalSiderealTime));
            };

            // Horizontal grid
            GridHorizontal.FromHorizontal = (h) => new GridPoint(h.Azimuth, h.Altitude);
            GridHorizontal.ToHorizontal   = (c) => new CrdsHorizontal(c.Longitude, c.Latitude);

            // Equatorial grid
            GridEquatorial.FromHorizontal = (h) =>
            {
                var eq = h.ToEquatorial(GeoLocation, LocalSiderealTime);
                return(new GridPoint(eq.Alpha, eq.Delta));
            };
            GridEquatorial.ToHorizontal = (c) =>
            {
                var eq = new CrdsEquatorial(c.Longitude, c.Latitude);
                return(eq.ToHorizontal(GeoLocation, LocalSiderealTime));
            };
        }
Example #3
0
        /// <summary>
        /// Gets drawing rotation of image, measured clockwise from
        /// a point oriented to top of the screen towards North celestial pole point
        /// </summary>
        /// <param name="eq">Equatorial coordinates of a central point of a body.</param>
        /// <returns></returns>
        public static float GetRotationTowardsNorth(this IMapContext map, CrdsEquatorial eq)
        {
            // Coordinates of center of a body (image) to be rotated
            PointF p = map.Project(eq.ToHorizontal(map.GeoLocation, map.SiderealTime));

            // Point directed to North celestial pole
            PointF pNorth = map.Project((eq + new CrdsEquatorial(0, 1)).ToHorizontal(map.GeoLocation, map.SiderealTime));

            // Clockwise rotation
            return(LineInclinationY(p, pNorth));
        }
        public override void Initialize()
        {
            // Ecliptic
            LineEcliptic.FromHorizontal = (h, ctx) =>
            {
                var eq = h.ToEquatorial(ctx.GeoLocation, ctx.SiderealTime);
                var ec = eq.ToEcliptical(ctx.Epsilon);
                return(new GridPoint(ec.Lambda, ec.Beta));
            };
            LineEcliptic.ToHorizontal = (c, ctx) =>
            {
                var ec = new CrdsEcliptical(c.Longitude, c.Latitude);
                var eq = ec.ToEquatorial(ctx.Epsilon);
                return(eq.ToHorizontal(ctx.GeoLocation, ctx.SiderealTime));
            };

            // Galactic equator
            LineGalactic.FromHorizontal = (h, ctx) =>
            {
                var eq     = h.ToEquatorial(ctx.GeoLocation, ctx.SiderealTime);
                var eq1950 = Precession.GetEquatorialCoordinates(eq, peTo1950);
                var gal    = eq1950.ToGalactical();
                return(new GridPoint(gal.l, gal.b));
            };
            LineGalactic.ToHorizontal = (c, ctx) =>
            {
                var gal    = new CrdsGalactical(c.Longitude, c.Latitude);
                var eq1950 = gal.ToEquatorial();
                var eq     = Precession.GetEquatorialCoordinates(eq1950, peFrom1950);
                return(eq.ToHorizontal(ctx.GeoLocation, ctx.SiderealTime));
            };

            // Meridian line
            LineMeridian.FromHorizontal = (h, ctx) => new GridPoint(0, h.Azimuth - 180);
            LineMeridian.ToHorizontal   = (c, context) => new CrdsHorizontal(0, c.Longitude - 180);

            // Horizontal grid
            GridHorizontal.FromHorizontal = (h, ctx) => new GridPoint(h.Azimuth, h.Altitude);
            GridHorizontal.ToHorizontal   = (c, context) => new CrdsHorizontal(c.Longitude, c.Latitude);

            // Equatorial grid
            GridEquatorial.FromHorizontal = (h, ctx) =>
            {
                var eq = h.ToEquatorial(ctx.GeoLocation, ctx.SiderealTime);
                return(new GridPoint(eq.Alpha, eq.Delta));
            };
            GridEquatorial.ToHorizontal = (c, ctx) =>
            {
                var eq = new CrdsEquatorial(c.Longitude, c.Latitude);
                return(eq.ToHorizontal(ctx.GeoLocation, ctx.SiderealTime));
            };
        }