Пример #1
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);
        }
Пример #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);
        }
Пример #3
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));
        }
Пример #4
0
        /// <summary>
        /// Calculates ecliptical geocentric coordinates of Pluto for current epoch
        /// </summary>
        private CrdsEcliptical Pluto_Ecliptical(SkyContext c)
        {
            CrdsEcliptical plutoEcliptical = c.Get(Pluto_Equatorial0).ToEcliptical(c.Epsilon);

            plutoEcliptical.Distance = c.Get(Pluto_EclipticalJ2000).Distance;
            return(plutoEcliptical);
        }
Пример #5
0
        public void Phase_PhaseAngle_Elongation()
        {
            CrdsEquatorial eqSun  = new CrdsEquatorial(20.6579, 8.6964);
            CrdsEquatorial eqMoon = new CrdsEquatorial(134.6855, 13.7684);

            const double epslion = 23.440636;

            CrdsEcliptical sun = eqSun.ToEcliptical(epslion);

            sun.Distance = 149971520;

            CrdsEcliptical moon = eqMoon.ToEcliptical(epslion);

            moon.Distance = 368410;

            double psi = BasicEphem.Elongation(sun, moon);

            Assert.AreEqual(110.79, psi, 1e-2);

            double phaseAngle = BasicEphem.PhaseAngle(psi, sun.Distance, moon.Distance);

            Assert.AreEqual(69.08, phaseAngle, 1e-2);

            double phase = BasicEphem.Phase(phaseAngle);

            Assert.AreEqual(0.68, phase, 1e-2);
        }
Пример #6
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));
            };
        }
Пример #7
0
        /// <summary>
        /// Calculates ecliptical coordinates of Pluto for J2000.0 epoch
        /// </summary>
        private CrdsEcliptical Pluto_EclipticalJ2000(SkyContext c)
        {
            CrdsHeliocentrical plutoHeliocentrial  = c.Get(Pluto_HeliocentricalJ2000);
            CrdsHeliocentrical earthHeliocentrical = c.Get(Earth_HeliocentricalJ2000);
            CrdsEcliptical     plutoEcliptical     = plutoHeliocentrial.ToRectangular(earthHeliocentrical).ToEcliptical();

            return(plutoEcliptical);
        }
Пример #8
0
        public void EquatorialToEcliptical()
        {
            CrdsEquatorial eq = new CrdsEquatorial(new HMS("7h 45m 18.946s"), new DMS("+28* 01' 34.26''"));

            CrdsEcliptical ecl = eq.ToEcliptical(23.4392911);

            Assert.AreEqual(113.215630, ecl.Lambda, errorInDMS);
            Assert.AreEqual(6.684170, ecl.Beta, errorInDMS);
        }
Пример #9
0
        public void EclipticalToRectangular()
        {
            CrdsEcliptical ecl = new CrdsEcliptical(199.907347, 0.62 / 3600.0, 0.99760775);

            CrdsRectangular rect = ecl.ToRectangular(23.4402297);

            Assert.AreEqual(-0.9379952, rect.X, 1e-7);
            Assert.AreEqual(-0.3116544, rect.Y, 1e-7);
            Assert.AreEqual(-0.1351215, rect.Z, 1e-7);
        }
Пример #10
0
        /// <summary>
        /// Gets apparent geocentrical ecliptical coordinates of the Moon
        /// </summary>
        private CrdsEcliptical Ecliptical0(SkyContext c)
        {
            // geocentrical coordinates of the Moon
            CrdsEcliptical ecliptical0 = LunarMotion.GetCoordinates(c.JulianDay);

            // apparent geocentrical ecliptical coordinates
            ecliptical0 += Nutation.NutationEffect(c.NutationElements.deltaPsi);

            return(ecliptical0);
        }
Пример #11
0
        public void Libration()
        {
            double         jd       = 2448724.5;
            CrdsEcliptical ecl      = new CrdsEcliptical(133.167260, -3.229127);
            double         deltaPsi = 0.004610;

            Libration le = LunarEphem.Libration(jd, ecl, deltaPsi);

            Assert.AreEqual(-1.23, le.l, 1e-2);
            Assert.AreEqual(4.20, le.b, 1e-2);
        }
Пример #12
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);
        }
Пример #13
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));
        }
Пример #14
0
        public void PositionAngleOfAxis()
        {
            double         jd       = 2448724.5;
            CrdsEcliptical ecl      = new CrdsEcliptical(new DMS("133* 10' 00''"), new DMS("-3* 13' 45''"));
            double         epsilon  = 23.440636;
            double         deltaPsi = 0.004610;

            double P = LunarEphem.PositionAngleOfAxis(jd, ecl, epsilon, deltaPsi);

            Assert.AreEqual(15.08, P, 1e-2);
        }
Пример #15
0
        private CrdsRectangular SunRectangular(double jd, double epsilon)
        {
            CrdsHeliocentrical hEarth = PlanetPositions.GetPlanetCoordinates(3, jd, true, false);

            var eSun = new CrdsEcliptical(Angle.To360(hEarth.L + 180), -hEarth.B, hEarth.R);

            // Corrected solar coordinates to FK5 system
            // NO correction for nutation and aberration should be performed here (ch. 26, p. 171)
            eSun += PlanetPositions.CorrectionForFK5(jd, eSun);

            return(eSun.ToRectangular(epsilon));
        }
Пример #16
0
        /// <summary>
        /// Gets ecliptical coordinates of Sun for J2000.0 epoch
        /// </summary>
        private CrdsEcliptical SunEcliptical(SkyContext c)
        {
            CrdsHeliocentrical hEarth = PlanetPositions.GetPlanetCoordinates(3, c.JulianDay, !c.PreferFastCalculation, false);

            var eSun = new CrdsEcliptical(Angle.To360(hEarth.L + 180), -hEarth.B, hEarth.R);

            // Corrected solar coordinates to FK5 system
            // NO correction for nutation and aberration should be performed here (ch. 26, p. 171)
            eSun += PlanetPositions.CorrectionForFK5(c.JulianDay, eSun);

            return(eSun);
        }
Пример #17
0
        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));
            };
        }
Пример #18
0
        /// <summary>
        /// Calculates Sun rectangular coordinates for J2000 epoch
        /// </summary>
        private CrdsRectangular Sun_RectangularJ2000(SkyContext c)
        {
            // Heliocentrical coordinates of Earth
            CrdsHeliocentrical hEarth = c.Get(Earth_HeliocentricalJ2000);

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

            // Sun rectangular coordinates, J2000.0 epoch
            CrdsRectangular rSun = eclSun.ToRectangular(epsilonJ2000);

            return(rSun);
        }
Пример #19
0
        /// <summary>
        /// Gets ecliptical coordinates of Sun
        /// </summary>
        public CrdsEcliptical Sun_Ecliptical(SkyContext c)
        {
            CrdsHeliocentrical hEarth = c.Get(Earth_Heliocentrial);
            var sunEcliptical         = new CrdsEcliptical(Angle.To360(hEarth.L + 180), -hEarth.B, hEarth.R);

            // Corrected solar coordinates to FK5 system
            sunEcliptical += PlanetPositions.CorrectionForFK5(c.JulianDay, sunEcliptical);

            // Add nutation effect to ecliptical coordinates of the Sun
            sunEcliptical += Nutation.NutationEffect(c.NutationElements.deltaPsi);

            // Add aberration effect, so we have an final ecliptical coordinates of the Sun
            sunEcliptical += Aberration.AberrationEffect(sunEcliptical.Distance);

            return(sunEcliptical);
        }
Пример #20
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));
        }
Пример #21
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));
        }
Пример #22
0
        /// <summary>
        /// Gets apparent geocentrical ecliptical coordinates of the Sun
        /// </summary>
        private CrdsEcliptical SunEcliptical(SkyContext c)
        {
            // get Earth coordinates
            CrdsHeliocentrical hEarth = c.Get(EarthHeliocentrical);

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

            // correct solar coordinates to FK5 system
            sunEcliptical += PlanetPositions.CorrectionForFK5(c.JulianDay, sunEcliptical);

            // add nutation effect to ecliptical coordinates of the Sun
            sunEcliptical += Nutation.NutationEffect(c.NutationElements.deltaPsi);

            // add aberration effect, so we have an final ecliptical coordinates of the Sun
            sunEcliptical += Aberration.AberrationEffect(sunEcliptical.Distance);

            return(sunEcliptical);
        }
Пример #23
0
        public CrdsEcliptical Ecliptical(SkyContext c)
        {
            // get Earth coordinates
            CrdsHeliocentrical crds = PlanetPositions.GetPlanetCoordinates(Planet.EARTH, c.JulianDay, highPrecision: true);

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

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

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

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

            // add aberration effect
            ecl += Aberration.AberrationEffect(ecl.Distance);

            return(ecl);
        }
Пример #24
0
        private CrdsRectangular NeptuneMoon_Rectangular(SkyContext c, int m)
        {
            CrdsEquatorial moonEq     = c.Get(NeptuneMoon_Equatorial, m);
            CrdsEcliptical moonEcl    = c.Get(NeptuneMoon_Ecliptical, m);
            CrdsEquatorial neptuneEq  = c.Get(Planet_Equatorial, Planet.NEPTUNE);
            CrdsEcliptical neptuneEcl = c.Get(Planet_Ecliptical, Planet.NEPTUNE);

            double sd = c.Get(Planet_Semidiameter, Planet.NEPTUNE) / 3600;
            double P  = c.Get(Planet_Appearance, Planet.NEPTUNE).P;

            double[] alpha = new double[] { moonEq.Alpha, neptuneEq.Alpha };
            Angle.Align(alpha);

            double[] delta = new double[] { moonEq.Delta, neptuneEq.Delta };

            double x = (alpha[0] - alpha[1]) * Math.Cos(Angle.ToRadians(neptuneEq.Delta)) / sd;
            double y = (delta[0] - delta[1]) / sd;

            // radius-vector of moon, in planet's equatorial radii
            double r = Math.Sqrt(x * x + y * y);

            // rotation angle
            double theta = Angle.ToDegrees(Math.Atan2(x, y));

            // rotate with position angle of the planet
            theta -= P;

            // convert back to rectangular coordinates, but rotated with P angle:
            y = r * Math.Cos(Angle.ToRadians(theta));
            x = -r *Math.Sin(Angle.ToRadians(theta));

            const double NEPTUNE_RADIUS = 24622;
            const double AU             = 149597870;

            // z is expressed in Uranus equatorial radii
            double z = (moonEcl.Distance - neptuneEcl.Distance) / (2 * NEPTUNE_RADIUS / AU);

            return(new CrdsRectangular(x, y, z));
        }
Пример #25
0
        public static void Rotate(this IMapContext map, PointF p, CrdsEcliptical ecl)
        {
            // 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
            float inc = LineInclinationY(p, pNorth);

            if (map.IsInverted)
            {
                inc = -90 - inc;
            }
            float rotation = (float)inc;

            if (map.IsInverted)
            {
                rotation = 90 - rotation;
            }

            map.Graphics.TranslateTransform(p.X, p.Y);
            map.Graphics.RotateTransform(rotation);
        }
Пример #26
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);
        }
Пример #27
0
        /// <summary>
        /// Calculates heliocentrical coordinates of Pluto for J2000 epoch
        /// </summary>
        private CrdsHeliocentrical Pluto_HeliocentricalJ2000(SkyContext c)
        {
            // final difference to stop iteration process, 1 second of time
            double deltaTau = TimeSpan.FromSeconds(1).TotalDays;

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

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

            // Sun rectangular coordinates, J2000.0 epoch
            CrdsRectangular rSun = c.Get(Sun_RectangularJ2000);

            // Heliocentrical coordinates of Pluto
            CrdsHeliocentrical plutoHeliocentrial = null;

            // Iterative process to find heliocentrical coordinates of planet
            while (Math.Abs(tau - tau0) > deltaTau)
            {
                // Heliocentrical coordinates of Pluto
                plutoHeliocentrial = PlutoPosition.Position(c.JulianDay - tau);

                // Rectangular heliocentrical coordinates of Pluto
                CrdsRectangular rPluto = new CrdsEcliptical(plutoHeliocentrial.L, plutoHeliocentrial.B, plutoHeliocentrial.R).ToRectangular(epsilonJ2000);

                double x    = rPluto.X + rSun.X;
                double y    = rPluto.Y + rSun.Y;
                double z    = rPluto.Z + rSun.Z;
                double dist = Math.Sqrt(x * x + y * y + z * z);

                tau0 = tau;
                tau  = PlanetPositions.LightTimeEffect(dist);
            }

            return(plutoHeliocentrial);
        }
Пример #28
0
 public void Separation()
 {
     // Example 17.a, AA(II)
     {
         var c1 = new CrdsEquatorial(213.9154, 19.1825);
         var c2 = new CrdsEquatorial(201.2983, -11.1614);
         Assert.AreEqual(32.7930, Angle.Separation(c1, c2), 1e-4);
     }
     {
         var c1 = new CrdsEcliptical(213.9154, 19.1825);
         var c2 = new CrdsEcliptical(201.2983, -11.1614);
         Assert.AreEqual(32.7930, Angle.Separation(c1, c2), 1e-4);
     }
     {
         var c1 = new CrdsGeographical(213.9154, 19.1825);
         var c2 = new CrdsGeographical(201.2983, -11.1614);
         Assert.AreEqual(32.7930, Angle.Separation(c1, c2), 1e-4);
     }
     {
         var c1 = new CrdsHorizontal(213.9154, 19.1825);
         var c2 = new CrdsHorizontal(201.2983, -11.1614);
         Assert.AreEqual(32.7930, Angle.Separation(c1, c2), 1e-4);
     }
 }
Пример #29
0
        public void Noumenia()
        {
            // Example are taken from
            // http://www.makkahcalendar.org/en/islamicCalendarArticle4.php

            // IX.4 Example of Makkah
            {
                // 17 Nov 2009, "best time" is 14:48 UTC
                double jd = new Date(new DateTime(2009, 11, 17, 14, 48, 0, DateTimeKind.Utc)).ToJulianEphemerisDay();

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

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

                // Sidereal time at Greenwich
                double siderealTime = Date.ApparentSiderealTime(jd, nutation.deltaPsi, epsilon);

                // Ecliptical coordinates of the Sun, taken from the example (see ref.)
                CrdsEcliptical eclSun = new CrdsEcliptical(235.39, 0);

                // Ecliptical coordinates of the Moon, taken from the example (see ref.)
                CrdsEcliptical eclMoon = new CrdsEcliptical(245.01, -3.76);

                // Geograhical coordinates of Makkah
                CrdsGeographical geo = new CrdsGeographical(-39.82563, 21.42664);

                double q = LunarEphem.CrescentQ(eclMoon, eclSun, 0.2539 * 3600, epsilon, siderealTime, geo);

                Assert.AreEqual(-0.465, q, 0.001);
            }

            // IX.5 Example of intermediate horizon 30°W, 30°S at 21:04
            {
                // 17 Nov 2009, 21:04 UTC
                double jd = new Date(new DateTime(2009, 11, 17, 21, 04, 0, DateTimeKind.Utc)).ToJulianEphemerisDay();

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

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

                // Sidereal time at Greenwich
                double siderealTime = Date.ApparentSiderealTime(jd, nutation.deltaPsi, epsilon);

                // Ecliptical coordinates of the Sun, taken from the example (see ref.)
                CrdsEcliptical eclSun = new CrdsEcliptical(235.65, 0);

                // Ecliptical coordinates of the Moon, taken from the example (see ref.)
                CrdsEcliptical eclMoon = new CrdsEcliptical(248.32, -3.55);

                // Geograhical coordinates of Makkah
                CrdsGeographical geo = new CrdsGeographical(30, -30);

                double q = LunarEphem.CrescentQ(eclMoon, eclSun, 0.2536 * 3600, epsilon, siderealTime, geo);

                Assert.AreEqual(0.367, q, 0.001);
            }
        }
Пример #30
0
        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);
            }
        }