Example #1
0
        public void CalculatePlanetApparentPlaceLP()
        {
            double jde = 2448976.5;

            double         tau = 0;
            CrdsEcliptical ecl = null;

            for (int i = 0; i < 2; i++)
            {
                CrdsHeliocentrical hEarth = PlanetPositions.GetPlanetCoordinates(3, jde - tau, highPrecision: false);

                CrdsHeliocentrical hVenus = PlanetPositions.GetPlanetCoordinates(2, jde - tau, highPrecision: false);

                var rect = hVenus.ToRectangular(hEarth);

                ecl = rect.ToEcliptical();

                tau = PlanetPositions.LightTimeEffect(ecl.Distance);
            }

            // Correction for FK5 system
            CrdsEcliptical corr = PlanetPositions.CorrectionForFK5(jde, ecl);

            ecl += corr;
            ecl += Nutation.NutationEffect(16.749 / 3600.0);

            CrdsEquatorial eq = ecl.ToEquatorial(23.439669);

            Assert.AreEqual(new HMS("21h 04m 41.459s"), new HMS(eq.Alpha));
            Assert.AreEqual(new DMS("-18* 53' 16.66''"), new DMS(eq.Delta));
        }
Example #2
0
        public void GetSolarCoordinatesLP()
        {
            double jde = 2448908.5;

            // get Earth coordinates
            CrdsHeliocentrical crds = PlanetPositions.GetPlanetCoordinates(Planet.Earth, jde, highPrecision: false);

            Assert.AreEqual(19.907372, crds.L, 1e-6);
            Assert.AreEqual(-0.644, crds.B * 3600, 1e-3);
            Assert.AreEqual(0.99760775, crds.R, 1e-8);

            // transform to ecliptical coordinates of the Sun
            CrdsEcliptical ecl = new CrdsEcliptical(Angle.To360(crds.L + 180), -crds.B, crds.R);

            // get FK5 system correction
            CrdsEcliptical corr = PlanetPositions.CorrectionForFK5(jde, ecl);

            Assert.AreEqual(-0.09033, corr.Lambda * 3600, 1e-5);
            Assert.AreEqual(-0.023, corr.Beta * 3600, 1e-3);

            // correct solar coordinates to FK5 system
            ecl += corr;

            Assert.AreEqual(199.907347, ecl.Lambda, 1e-6);
            Assert.AreEqual(0.62, ecl.Beta * 3600, 1e-2);
            Assert.AreEqual(0.99760775, ecl.Distance, 1e-8);

            var nutation = Nutation.NutationElements(jde);

            // True obliquity
            double epsilon = Date.TrueObliquity(jde, nutation.deltaEpsilon);

            // accuracy is 0.5"
            Assert.AreEqual(15.908, nutation.deltaPsi * 3600, 0.5);

            // accuracyis 0.1"
            Assert.AreEqual(-0.308, nutation.deltaEpsilon * 3600, 0.1);

            // accuracy is 0.1"
            Assert.AreEqual(23.4401443, epsilon, 0.1 / 3600.0);

            // add nutation effect
            ecl += Nutation.NutationEffect(nutation.deltaPsi);

            // calculate aberration effect
            CrdsEcliptical aberration = Aberration.AberrationEffect(ecl.Distance);

            Assert.AreEqual(-20.539, aberration.Lambda * 3600.0, 1e-3);

            // add aberration effect
            ecl += aberration;

            // convert ecliptical to equatorial coordinates
            CrdsEquatorial eq = ecl.ToEquatorial(epsilon);

            // check apparent equatorial coordinates
            // assume an accuracy of 0.5'' is sufficient
            Assert.AreEqual(198.378178, eq.Alpha, 1.0 / 3600 * 0.5);
            Assert.AreEqual(-7.783871, eq.Delta, 1.0 / 3600 * 0.5);
        }
Example #3
0
        public void GetCoordinates()
        {
            double jd = 2448724.5;

            // geocentrical coordinates
            CrdsEcliptical ecl = LunarMotion.GetCoordinates(jd);

            Assert.AreEqual(133.162655, ecl.Lambda, 1e-6);
            Assert.AreEqual(-3.229126, ecl.Beta, 1e-6);
            Assert.AreEqual(368409.7, ecl.Distance, 1e-1);

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

            // apparent geocentrical ecliptical coordinates
            ecl += Nutation.NutationEffect(nutation.deltaPsi);

            // true obliquity of the Earth orbit
            double epsilon = Date.TrueObliquity(jd, nutation.deltaEpsilon);

            // equatorial geocentrical coordinates
            CrdsEquatorial eq = ecl.ToEquatorial(epsilon);

            // Max error in Right Ascention is 0.1" of time
            double errAlpha = new HMS("0h 0m 00.1s").ToDecimalAngle();

            // Max error in Declination is 1" of arc
            double errDelta = new DMS("0* 0' 01''").ToDecimalAngle();

            Assert.AreEqual(new HMS("8h 58m 45.2s").ToDecimalAngle(), eq.Alpha, errAlpha);
            Assert.AreEqual(new DMS("+13* 46' 06''").ToDecimalAngle(), eq.Delta, errDelta);
        }
Example #4
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 #5
0
        public void EclipticalToEquatorial()
        {
            CrdsEcliptical ecl = new CrdsEcliptical(113.215630, 6.684170);

            CrdsEquatorial eq = ecl.ToEquatorial(23.4392911);

            CrdsEquatorial eqExpected = new CrdsEquatorial(new HMS("7h 45m 18.946s"), new DMS("+28* 01' 34.26''"));

            Assert.AreEqual(eqExpected.Alpha, eq.Alpha, errorInHMS);
            Assert.AreEqual(eqExpected.Delta, eq.Delta, errorInDMS);
        }
Example #6
0
        /// <summary>
        /// Gets drawing rotation of image, measured clockwise from
        /// a point oriented to top of the screen towards North ecliptic pole point
        /// </summary>
        /// <param name="ecl">Ecliptical coordinates of a central point of a body.</param>
        /// <returns></returns>
        public static float GetRotationTowardsEclipticPole(this IMapContext map, CrdsEcliptical ecl)
        {
            // Coordinates of center of a body (image) to be rotated
            PointF p = map.Project(ecl.ToEquatorial(map.Epsilon).ToHorizontal(map.GeoLocation, map.SiderealTime));

            // Point directed to North ecliptic pole
            PointF pNorth = map.Project((ecl + new CrdsEcliptical(0, 1)).ToEquatorial(map.Epsilon).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));
            };
        }
Example #8
0
        /// <summary>
        /// Gets horizontal topocentrical coordinates of Earth Shadow
        /// </summary>
        private CrdsHorizontal EarthShadowCoordinates(SkyContext c)
        {
            // Ecliptical coordinates of Sun
            var eclSun = c.Get(SunEcliptical);

            // Coordinates of Earth shadow is an opposite point on the celestial sphere
            var eclShadow = new CrdsEcliptical(eclSun.Lambda + 180, -eclSun.Beta);

            // Equatorial geocentrical coordinates of the shadow center
            var eq0 = eclShadow.ToEquatorial(c.Epsilon);

            // Topocentrical equatorial coordinates
            var eq = eq0.ToTopocentric(c.GeoLocation, c.SiderealTime, c.Get(Parallax));

            // finally get the horizontal coordinates
            return(eq.ToHorizontal(c.GeoLocation, c.SiderealTime));
        }
Example #9
0
        public void CalculatePlanetApparentPlaceHP()
        {
            double jde = 2448976.5;

            // time taken by the light to reach the Earth
            double tau = 0;

            // previous value of tau to calculate the difference
            double tau0 = 1;

            // final difference to stop iteration process, 1 second of time
            double deltaTau = TimeSpan.FromSeconds(1).TotalDays;

            // Ecliptical coordinates of Venus
            CrdsEcliptical ecl = null;

            // Iterative process to find ecliptical coordinates of Venus
            while (Math.Abs(tau - tau0) > deltaTau)
            {
                // Heliocentrical coordinates of Earth
                var hEarth = PlanetPositions.GetPlanetCoordinates(3, jde - tau, highPrecision: true);

                // Heliocentrical coordinates of Venus
                var hVenus = PlanetPositions.GetPlanetCoordinates(2, jde - tau, highPrecision: true);

                // Ecliptical coordinates of Venus
                ecl = hVenus.ToRectangular(hEarth).ToEcliptical();

                tau0 = tau;
                tau  = PlanetPositions.LightTimeEffect(ecl.Distance);
            }

            // Correction for FK5 system
            ecl += PlanetPositions.CorrectionForFK5(jde, ecl);

            // Take nutation into account
            ecl += Nutation.NutationEffect(16.749 / 3600.0);

            // Apparent equatorial coordinates of Venus
            CrdsEquatorial eq = ecl.ToEquatorial(23.439669);

            Assert.AreEqual(new HMS("21h 04m 41.454s"), new HMS(eq.Alpha));
            Assert.AreEqual(new DMS("-18* 53' 16.84''"), new DMS(eq.Delta));
        }
Example #10
0
        public void GetSolarCoordinatesLP()
        {
            double jde = 2448908.5;

            // get Earth coordinates
            CrdsHeliocentrical crds = PlanetPositions.GetPlanetCoordinates(3, jde, highPrecision: false);

            // transform to ecliptical coordinates of the Sun
            CrdsEcliptical ecl = new CrdsEcliptical(Angle.To360(crds.L + 180), -crds.B, crds.R);

            // get FK5 system correction
            CrdsEcliptical corr = PlanetPositions.CorrectionForFK5(jde, ecl);

            // correct solar coordinates to FK5 system
            ecl += corr;

            var nutation = Nutation.NutationElements(jde);

            // True obliquity
            double epsilon = Date.TrueObliquity(jde, nutation.deltaEpsilon);

            // add nutation effect
            ecl += Nutation.NutationEffect(nutation.deltaPsi);

            // calculate aberration effect
            CrdsEcliptical aberration = Aberration.AberrationEffect(ecl.Distance);

            // add aberration effect
            ecl += aberration;

            // convert ecliptical to equatorial coordinates
            CrdsEquatorial eq = ecl.ToEquatorial(epsilon);

            // check apparent equatorial coordinates
            // assume an accuracy of 0.5'' is sufficient
            Assert.AreEqual(198.378178, eq.Alpha, 1.0 / 3600 * 0.5);
            Assert.AreEqual(-7.783871, eq.Delta, 1.0 / 3600 * 0.5);
        }
        public void Positions()
        {
            // Test data is obtained from NASA JPL Ephemeris tool
            // https://ssd.jpl.nasa.gov/horizons.cgi

            List <TestData> testDatas = new List <TestData>()
            {
                // Triton
                // 2020-Jan-07 13:00 2458856.041666667    -0.964   12.797
                new TestData()
                {
                    MoonNumber = 1,
                    Neptune    = new CrdsEcliptical(new DMS("346* 24' 16.12''"), new DMS("-1* 01' 26.26''"), 30.416),
                    JulianDay  = 2458856.041666667,
                    X          = -0.964,
                    Y          = 12.797
                },

                // Triton
                // 2025-Jan-22 19:00 2460698.291666667        1.086  -12.382
                new TestData()
                {
                    MoonNumber = 1,
                    Neptune    = new CrdsEcliptical(new DMS("357° 43' 31.73''"), new DMS("-1° 16' 24.69''"), 30.416),
                    JulianDay  = 2460698.291666667,
                    X          = 1.086,
                    Y          = -12.382
                },

                // Nereid
                // 2020-Feb-27 00:00 2458906.500000000        5.124   10.556
                new TestData()
                {
                    MoonNumber = 2,
                    Neptune    = new CrdsEcliptical(new DMS("348* 00' 11.97''"), new DMS("-1* 00' 54.27''"), 30.906),
                    JulianDay  = 2458906.5,
                    X          = 5.124,
                    Y          = 10.556
                },

                // Nereid
                // 2020-Jul-13 00:00 2459043.500000000      384.491  206.269
                new TestData()
                {
                    MoonNumber = 2,
                    Neptune    = new CrdsEcliptical(new DMS("350* 51' 10.8''"), new DMS("-1* 05' 15.56''"), 29.405),
                    JulianDay  = 2459043.5,
                    X          = 384.491,
                    Y          = 206.269
                },

                // Nereid
                // 1980-Jan-01 00:00 2444239.500000000      135.407   32.771
                new TestData()
                {
                    MoonNumber = 2,
                    Neptune    = new CrdsEcliptical(new DMS("260* 55' 41.93''"), new DMS("+1* 20' 26.28''"), 31.209),
                    JulianDay  = 2444239.5,
                    X          = 135.407,
                    Y          = 32.771
                }
            };

            // possible error in coordinates is 1 arcsecond
            const double error = 1;

            foreach (var testData in testDatas)
            {
                NutationElements ne           = Nutation.NutationElements(testData.JulianDay);
                double           epsilon      = Date.TrueObliquity(testData.JulianDay, ne.deltaEpsilon);
                CrdsEcliptical   eclSatellite = NeptunianMoons.Position(testData.JulianDay, testData.Neptune, testData.MoonNumber);

                CrdsEquatorial eqNeptune   = testData.Neptune.ToEquatorial(epsilon);
                CrdsEquatorial eqSatellite = eclSatellite.ToEquatorial(epsilon);

                double X = (eqSatellite.Alpha - eqNeptune.Alpha) * Math.Cos(Angle.ToRadians(eqNeptune.Delta)) * 3600;
                double Y = (eqSatellite.Delta - eqNeptune.Delta) * 3600;

                Assert.AreEqual(testData.X, X, error);
                Assert.AreEqual(testData.Y, Y, error);
            }
        }