Esempio n. 1
0
        public void GalacticalToEquatorial()
        {
            CrdsEquatorial eqExpected = new CrdsEquatorial(new HMS("17h 48m 59.74s"), new DMS("-14* 43' 08.2''"));

            CrdsGalactical gal = new CrdsGalactical(12.9593, 6.0463);

            CrdsEquatorial eq = gal.ToEquatorial();

            Assert.AreEqual(eqExpected.Alpha, eq.Alpha, 1e-4);
            Assert.AreEqual(eqExpected.Delta, eq.Delta, 1e-4);
        }
        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));
            };
        }