Exemple #1
0
        public static double SpringEquinox(long Year)
        {
            //calculate the approximate date
            double JDE;

            if (Year <= 1000)
            {
                double Y        = Year / 1000.0;
                double Ysquared = Y * Y;
                double Ycubed   = Ysquared * Y;
                double Y4       = Ycubed * Y;
                JDE = 1721139.29189 + 365242.13740 * Y + 0.06134 * Ysquared + 0.00111 * Ycubed - 0.00071 * Y4;
            }
            else
            {
                double Y        = (Year - 2000) / 1000.0;
                double Ysquared = Y * Y;
                double Ycubed   = Ysquared * Y;
                double Y4       = Ycubed * Y;
                JDE = 2451623.80984 + 365242.37404 * Y + 0.05169 * Ysquared - 0.00411 * Ycubed - 0.00057 * Y4;
            }

            double Correction;

            do
            {
                double SunLongitude = AASSun.ApparentEclipticLongitude(JDE);
                Correction = 58 * Math.Sin(AASCoordinateTransformation.DegreesToRadians(-SunLongitude));
                JDE       += Correction;
            }while (Math.Abs(Correction) > 0.00001); //Corresponds to an error of 0.86 of a second

            return(JDE);
        }
Exemple #2
0
        public static AASSelenographicMoonDetails CalculateSelenographicPositionOfSun(double JD, bool bHighPrecision)
        {
            double R       = AASEarth.RadiusVector(JD, bHighPrecision) * 149597970;
            double Delta   = AASMoon.RadiusVector(JD);
            double lambda0 = AASSun.ApparentEclipticLongitude(JD, bHighPrecision);
            double lambda  = AASMoon.EclipticLongitude(JD);
            double beta    = AASMoon.EclipticLatitude(JD);

            double lambdah = AASCoordinateTransformation.MapTo0To360Range(lambda0 + 180 + Delta / R * 57.296 * Math.Cos(AASCoordinateTransformation.DegreesToRadians(beta)) * Math.Sin(AASCoordinateTransformation.DegreesToRadians(lambda0 - lambda)));
            double betah   = Delta / R * beta;

            //What will be the return value
            AASSelenographicMoonDetails details = new AASSelenographicMoonDetails();

            //Calculate the optical libration
            double omega   = 0;
            double DeltaU  = 0;
            double sigma   = 0;
            double I       = 0;
            double rho     = 0;
            double ldash0  = 0;
            double bdash0  = 0;
            double ldash20 = 0;
            double bdash20 = 0;
            double epsilon = 0;

            CalculateOpticalLibration(JD, lambdah, betah, ref ldash0, ref bdash0, ref ldash20, ref bdash20, ref epsilon, ref omega, ref DeltaU, ref sigma, ref I, ref rho);

            details.l0 = ldash0 + ldash20;
            details.b0 = bdash0 + bdash20;
            details.c0 = AASCoordinateTransformation.MapTo0To360Range(450 - details.l0);
            return(details);
        }
Exemple #3
0
        public static double AutumnEquinox(long Year)
        {
            //calculate the approximate date
            double JDE;

            if (Year <= 1000)
            {
                double Y        = Year / 1000.0;
                double Ysquared = Y * Y;
                double Ycubed   = Ysquared * Y;
                double Y4       = Ycubed * Y;
                JDE = 1721325.70455 + 365242.49558 * Y - 0.11677 * Ysquared - 0.00297 * Ycubed + 0.00074 * Y4;
            }
            else
            {
                double Y        = (Year - 2000) / 1000.0;
                double Ysquared = Y * Y;
                double Ycubed   = Ysquared * Y;
                double Y4       = Ycubed * Y;
                JDE = 2451810.21715 + 365242.01767 * Y - 0.11575 * Ysquared + 0.00337 * Ycubed + 0.00078 * Y4;
            }

            double Correction;

            do
            {
                double SunLongitude = AASSun.ApparentEclipticLongitude(JDE);
                Correction = 58 * Math.Sin(AASCoordinateTransformation.DegreesToRadians(180 - SunLongitude));
                JDE       += Correction;
            }while (Math.Abs(Correction) > 0.00001); //Corresponds to an error of 0.86 of a second

            return(JDE);
        }
Exemple #4
0
        public static double SummerSolstice(long Year)
        {
            //calculate the approximate date
            double JDE;

            if (Year <= 1000)
            {
                double Y        = Year / 1000.0;
                double Ysquared = Y * Y;
                double Ycubed   = Ysquared * Y;
                double Y4       = Ycubed * Y;
                JDE = 1721233.25401 + 365241.72562 * Y - 0.05323 * Ysquared + 0.00907 * Ycubed + 0.00025 * Y4;
            }
            else
            {
                double Y        = (Year - 2000) / 1000.0;
                double Ysquared = Y * Y;
                double Ycubed   = Ysquared * Y;
                double Y4       = Ycubed * Y;
                JDE = 2451716.56767 + 365241.62603 * Y + 0.00325 * Ysquared + 0.00888 * Ycubed - 0.00030 * Y4;
            }

            double Correction;

            do
            {
                double SunLongitude = AASSun.ApparentEclipticLongitude(JDE);
                Correction = 58 * Math.Sin(AASCoordinateTransformation.DegreesToRadians(90 - SunLongitude));
                JDE       += Correction;
            }while (Math.Abs(Correction) > 0.00001); //Corresponds to an error of 0.86 of a second

            return(JDE);
        }
Exemple #5
0
        public static double WinterSolstice(long Year)
        {
            //calculate the approximate date
            double JDE;

            if (Year <= 1000)
            {
                double Y        = Year / 1000.0;
                double Ysquared = Y * Y;
                double Ycubed   = Ysquared * Y;
                double Y4       = Ycubed * Y;
                JDE = 1721414.39987 + 365242.88257 * Y - 0.00769 * Ysquared - 0.00933 * Ycubed - 0.00006 * Y4;
            }
            else
            {
                double Y        = (Year - 2000) / 1000.0;
                double Ysquared = Y * Y;
                double Ycubed   = Ysquared * Y;
                double Y4       = Ycubed * Y;
                JDE = 2451900.05952 + 365242.74049 * Y - 0.06223 * Ysquared - 0.00823 * Ycubed + 0.00032 * Y4;
            }

            double Correction;

            do
            {
                double SunLongitude = AASSun.ApparentEclipticLongitude(JDE);
                Correction = 58 * Math.Sin(AASCoordinateTransformation.DegreesToRadians(270 - SunLongitude));
                JDE       += Correction;
            }while (Math.Abs(Correction) > 0.00001); //Corresponds to an error of 0.86 of a second

            return(JDE);
        }
        public static double Calculate(double JD)
        {
            double rho        = (JD - 2451545) / 365250;
            double rhosquared = rho * rho;
            double rhocubed   = rhosquared * rho;
            double rho4       = rhocubed * rho;
            double rho5       = rho4 * rho;

            //Calculate the Suns mean longitude
            double L0 = AASCoordinateTransformation.MapTo0To360Range(280.4664567 + 360007.6982779 * rho + 0.03032028 * rhosquared +
                                                                     rhocubed / 49931 - rho4 / 15300 - rho5 / 2000000);

            //Calculate the Suns apparent right ascension
            double          SunLong    = AASSun.ApparentEclipticLongitude(JD);
            double          SunLat     = AASSun.ApparentEclipticLatitude(JD);
            double          epsilon    = AASNutation.TrueObliquityOfEcliptic(JD);
            AAS2DCoordinate Equatorial = AASCoordinateTransformation.Ecliptic2Equatorial(SunLong, SunLat, epsilon);

            epsilon = AASCoordinateTransformation.DegreesToRadians(epsilon);
            double E = L0 - 0.0057183 - Equatorial.X * 15 + AASCoordinateTransformation.DMSToDegrees(0, 0, AASNutation.NutationInLongitude(JD)) * Math.Cos(epsilon);

            if (E > 180)
            {
                E = -(360 - E);
            }
            E *= 4; //Convert to minutes of time

            return(E);
        }
Exemple #7
0
        public static AAS2DCoordinate EclipticAberration(double Lambda, double Beta, double JD)
        {
            //What is the return value
            AAS2DCoordinate aberration = new AAS2DCoordinate();

            double       T            = (JD - 2451545) / 36525;
            double       Tsquared     = T * T;
            double       e            = 0.016708634 - 0.000042037 * T - 0.0000001267 * Tsquared;
            double       pi           = 102.93735 + 1.71946 * T + 0.00046 * Tsquared;
            const double k            = 20.49552;
            double       SunLongitude = AASSun.GeometricEclipticLongitude(JD);

            //Convert to radians
            pi           = AASCoordinateTransformation.DegreesToRadians(pi);
            Lambda       = AASCoordinateTransformation.DegreesToRadians(Lambda);
            Beta         = AASCoordinateTransformation.DegreesToRadians(Beta);
            SunLongitude = AASCoordinateTransformation.DegreesToRadians(SunLongitude);

            aberration.X = (-k * Math.Cos(SunLongitude - Lambda) + e * k * Math.Cos(pi - Lambda)) / Math.Cos(Beta) / 3600;
            aberration.Y = -k *Math.Sin(Beta) * (Math.Sin(SunLongitude - Lambda) - e * Math.Sin(pi - Lambda)) / 3600;

            return(aberration);
        }
        public static CAAPhysicalMarsDetails Calculate(double JD, bool bHighPrecision)
        {
            //What will be the return value
            CAAPhysicalMarsDetails details = new CAAPhysicalMarsDetails();

            //Step 1
            double T          = (JD - 2451545) / 36525;
            double Lambda0    = 352.9065 + 1.17330 * T;
            double Lambda0rad = AASCoordinateTransformation.DegreesToRadians(Lambda0);
            double Beta0      = 63.2818 - 0.00394 * T;
            double Beta0rad   = AASCoordinateTransformation.DegreesToRadians(Beta0);

            //Step 2
            double l0    = AASEarth.EclipticLongitude(JD, bHighPrecision);
            double l0rad = AASCoordinateTransformation.DegreesToRadians(l0);
            double b0    = AASEarth.EclipticLatitude(JD, bHighPrecision);
            double b0rad = AASCoordinateTransformation.DegreesToRadians(b0);
            double R     = AASEarth.RadiusVector(JD, bHighPrecision);

            double PreviousLightTravelTime = 0;
            double LightTravelTime         = 0;
            double x        = 0;
            double y        = 0;
            double z        = 0;
            bool   bIterate = true;
            double DELTA    = 0;
            double l        = 0;
            double lrad     = 0;
            double b        = 0;
            double r        = 0;

            while (bIterate)
            {
                double JD2 = JD - LightTravelTime;

                //Step 3
                l    = AASMars.EclipticLongitude(JD2, bHighPrecision);
                lrad = AASCoordinateTransformation.DegreesToRadians(l);
                b    = AASMars.EclipticLatitude(JD2, bHighPrecision);
                double brad = AASCoordinateTransformation.DegreesToRadians(b);
                r = AASMars.RadiusVector(JD2, bHighPrecision);

                //Step 4
                x               = r * Math.Cos(brad) * Math.Cos(lrad) - R * Math.Cos(l0rad);
                y               = r * Math.Cos(brad) * Math.Sin(lrad) - R * Math.Sin(l0rad);
                z               = r * Math.Sin(brad) - R * Math.Sin(b0rad);
                DELTA           = Math.Sqrt(x * x + y * y + z * z);
                LightTravelTime = AASElliptical.DistanceToLightTime(DELTA);

                //Prepare for the next loop around
                bIterate = (Math.Abs(LightTravelTime - PreviousLightTravelTime) > 2E-6); //2E-6 correponds to 0.17 of a second
                if (bIterate)
                {
                    PreviousLightTravelTime = LightTravelTime;
                }
            }

            //Step 5
            double lambdarad = Math.Atan2(y, x);
            double lambda    = AASCoordinateTransformation.RadiansToDegrees(lambdarad);
            double betarad   = Math.Atan2(z, Math.Sqrt(x * x + y * y));
            double beta      = AASCoordinateTransformation.RadiansToDegrees(betarad);

            //Step 6
            details.DE = AASCoordinateTransformation.RadiansToDegrees(Math.Asin(-Math.Sin(Beta0rad) * Math.Sin(betarad) - Math.Cos(Beta0rad) * Math.Cos(betarad) * Math.Cos(Lambda0rad - lambdarad)));

            //Step 7
            double N    = 49.5581 + 0.7721 * T;
            double Nrad = AASCoordinateTransformation.DegreesToRadians(N);

            double ldash    = l - 0.00697 / r;
            double ldashrad = AASCoordinateTransformation.DegreesToRadians(ldash);
            double bdash    = b - 0.000225 * (Math.Cos(lrad - Nrad) / r);
            double bdashrad = AASCoordinateTransformation.DegreesToRadians(bdash);

            //Step 8
            details.DS = AASCoordinateTransformation.RadiansToDegrees(Math.Asin(-Math.Sin(Beta0rad) * Math.Sin(bdashrad) - Math.Cos(Beta0rad) * Math.Cos(bdashrad) * Math.Cos(Lambda0rad - ldashrad)));

            //Step 9
            double W = AASCoordinateTransformation.MapTo0To360Range(11.504 + 350.89200025 * (JD - LightTravelTime - 2433282.5));

            //Step 10
            double          e0             = AASNutation.MeanObliquityOfEcliptic(JD);
            double          e0rad          = AASCoordinateTransformation.DegreesToRadians(e0);
            AAS2DCoordinate PoleEquatorial = AASCoordinateTransformation.Ecliptic2Equatorial(Lambda0, Beta0, e0);
            double          alpha0rad      = AASCoordinateTransformation.HoursToRadians(PoleEquatorial.X);
            double          delta0rad      = AASCoordinateTransformation.DegreesToRadians(PoleEquatorial.Y);

            //Step 11
            double u        = y * Math.Cos(e0rad) - z * Math.Sin(e0rad);
            double v        = y * Math.Sin(e0rad) + z * Math.Cos(e0rad);
            double alpharad = Math.Atan2(u, x);
            double alpha    = AASCoordinateTransformation.RadiansToHours(alpharad);
            double deltarad = Math.Atan2(v, Math.Sqrt(x * x + u * u));
            double delta    = AASCoordinateTransformation.RadiansToDegrees(deltarad);
            double xi       = Math.Atan2(Math.Sin(delta0rad) * Math.Cos(deltarad) * Math.Cos(alpha0rad - alpharad) - Math.Sin(deltarad) * Math.Cos(delta0rad), Math.Cos(deltarad) * Math.Sin(alpha0rad - alpharad));

            //Step 12
            details.w = AASCoordinateTransformation.MapTo0To360Range(W - AASCoordinateTransformation.RadiansToDegrees(xi));

            //Step 13
            double NutationInLongitude = AASNutation.NutationInLongitude(JD);
            double NutationInObliquity = AASNutation.NutationInObliquity(JD);

            //Step 14
            lambda += 0.005693 * Math.Cos(l0rad - lambdarad) / Math.Cos(betarad);
            beta   += 0.005693 * Math.Sin(l0rad - lambdarad) * Math.Sin(betarad);

            //Step 15
            Lambda0 += NutationInLongitude / 3600;
            lambda  += NutationInLongitude / 3600;
            e0      += NutationInObliquity / 3600;

            //Step 16
            AAS2DCoordinate ApparentPoleEquatorial = AASCoordinateTransformation.Ecliptic2Equatorial(Lambda0, Beta0, e0);
            double          alpha0dash             = AASCoordinateTransformation.HoursToRadians(ApparentPoleEquatorial.X);
            double          delta0dash             = AASCoordinateTransformation.DegreesToRadians(ApparentPoleEquatorial.Y);
            AAS2DCoordinate ApparentMars           = AASCoordinateTransformation.Ecliptic2Equatorial(lambda, beta, e0);
            double          alphadash = AASCoordinateTransformation.HoursToRadians(ApparentMars.X);
            double          deltadash = AASCoordinateTransformation.DegreesToRadians(ApparentMars.Y);

            //Step 17
            details.P = AASCoordinateTransformation.MapTo0To360Range(AASCoordinateTransformation.RadiansToDegrees(Math.Atan2(Math.Cos(delta0dash) * Math.Sin(alpha0dash - alphadash), Math.Sin(delta0dash) * Math.Cos(deltadash) - Math.Cos(delta0dash) * Math.Sin(deltadash) * Math.Cos(alpha0dash - alphadash))));

            //Step 18
            double          SunLambda     = AASSun.GeometricEclipticLongitude(JD, bHighPrecision);
            double          SunBeta       = AASSun.GeometricEclipticLatitude(JD, bHighPrecision);
            AAS2DCoordinate SunEquatorial = AASCoordinateTransformation.Ecliptic2Equatorial(SunLambda, SunBeta, e0);

            details.X = AASMoonIlluminatedFraction.PositionAngle(SunEquatorial.X, SunEquatorial.Y, alpha, delta);

            //Step 19
            details.d = 9.36 / DELTA;
            details.k = AASIlluminatedFraction.IlluminatedFraction(r, R, DELTA);
            details.q = (1 - details.k) * details.d;

            return(details);
        }
        public static AASNearParabolicObjectDetails Calculate(double JD, ref AASNearParabolicObjectElements elements, bool bHighPrecision)
        {
            double Epsilon = AASNutation.MeanObliquityOfEcliptic(elements.JDEquinox);

            double JD0 = JD;

            //What will be the return value
            AASNearParabolicObjectDetails details = new AASNearParabolicObjectDetails();

            Epsilon = AASCoordinateTransformation.DegreesToRadians(Epsilon);
            double omega = AASCoordinateTransformation.DegreesToRadians(elements.omega);
            double w     = AASCoordinateTransformation.DegreesToRadians(elements.w);
            double i     = AASCoordinateTransformation.DegreesToRadians(elements.i);

            double sinEpsilon = Math.Sin(Epsilon);
            double cosEpsilon = Math.Cos(Epsilon);
            double sinOmega   = Math.Sin(omega);
            double cosOmega   = Math.Cos(omega);
            double cosi       = Math.Cos(i);
            double sini       = Math.Sin(i);

            double F = cosOmega;
            double G = sinOmega * cosEpsilon;
            double H = sinOmega * sinEpsilon;
            double P = -sinOmega * cosi;
            double Q = cosOmega * cosi * cosEpsilon - sini * sinEpsilon;
            double R = cosOmega * cosi * sinEpsilon + sini * cosEpsilon;
            double a = Math.Sqrt(F * F + P * P);
            double b = Math.Sqrt(G * G + Q * Q);
            double c = Math.Sqrt(H * H + R * R);
            double A = Math.Atan2(F, P);
            double B = Math.Atan2(G, Q);
            double C = Math.Atan2(H, R);

            AAS3DCoordinate SunCoord = AASSun.EquatorialRectangularCoordinatesAnyEquinox(JD, elements.JDEquinox, bHighPrecision);

            for (int j = 0; j < 2; j++)
            {
                double v = 0;
                double r = 0;
                CalulateTrueAnnomalyAndRadius(JD0, ref elements, ref v, ref r);

                double x = r * a * Math.Sin(A + w + v);
                double y = r * b * Math.Sin(B + w + v);
                double z = r * c * Math.Sin(C + w + v);

                if (j == 0)
                {
                    details.HeliocentricRectangularEquatorial.X = x;
                    details.HeliocentricRectangularEquatorial.Y = y;
                    details.HeliocentricRectangularEquatorial.Z = z;

                    //Calculate the heliocentric ecliptic coordinates also
                    double u    = w + v;
                    double cosu = Math.Cos(u);
                    double sinu = Math.Sin(u);

                    details.HeliocentricRectangularEcliptical.X = r * (cosOmega * cosu - sinOmega * sinu * cosi);
                    details.HeliocentricRectangularEcliptical.Y = r * (sinOmega * cosu + cosOmega * sinu * cosi);
                    details.HeliocentricRectangularEcliptical.Z = r * sini * sinu;

                    details.HeliocentricEclipticLongitude = AASCoordinateTransformation.MapTo0To360Range(AASCoordinateTransformation.RadiansToDegrees(Math.Atan2(details.HeliocentricRectangularEcliptical.Y, details.HeliocentricRectangularEcliptical.X)));
                    details.HeliocentricEclipticLatitude  = AASCoordinateTransformation.RadiansToDegrees(Math.Asin(details.HeliocentricRectangularEcliptical.Z / r));
                }

                double psi   = SunCoord.X + x;
                double nu    = SunCoord.Y + y;
                double sigma = SunCoord.Z + z;

                double Alpha = Math.Atan2(nu, psi);
                Alpha = AASCoordinateTransformation.RadiansToDegrees(Alpha);
                double Delta = Math.Atan2(sigma, Math.Sqrt(psi * psi + nu * nu));
                Delta = AASCoordinateTransformation.RadiansToDegrees(Delta);
                double Distance = Math.Sqrt(psi * psi + nu * nu + sigma * sigma);

                if (j == 0)
                {
                    details.TrueGeocentricRA          = AASCoordinateTransformation.MapTo0To24Range(Alpha / 15);
                    details.TrueGeocentricDeclination = Delta;
                    details.TrueGeocentricDistance    = Distance;
                    details.TrueGeocentricLightTime   = AASElliptical.DistanceToLightTime(Distance);
                }
                else
                {
                    details.AstrometricGeocentricRA          = AASCoordinateTransformation.MapTo0To24Range(Alpha / 15);
                    details.AstrometricGeocentricDeclination = Delta;
                    details.AstrometricGeocentricDistance    = Distance;
                    details.AstrometricGeocentricLightTime   = AASElliptical.DistanceToLightTime(Distance);

                    double RES = Math.Sqrt(SunCoord.X * SunCoord.X + SunCoord.Y * SunCoord.Y + SunCoord.Z * SunCoord.Z);

                    details.Elongation = AASCoordinateTransformation.RadiansToDegrees(Math.Acos((RES * RES + Distance * Distance - r * r) / (2 * RES * Distance)));
                    details.PhaseAngle = AASCoordinateTransformation.RadiansToDegrees(Math.Acos((r * r + Distance * Distance - RES * RES) / (2 * r * Distance)));
                }

                if (j == 0) //Prepare for the next loop around
                {
                    JD0 = JD - details.TrueGeocentricLightTime;
                }
            }

            return(details);
        }
Exemple #10
0
        public static AASGalileanMoonsDetails Calculate(double JD, bool bHighPrecision)
        {
            //Calculate the position of the Sun
            double sunlong    = AASSun.GeometricEclipticLongitude(JD, bHighPrecision);
            double sunlongrad = AASCoordinateTransformation.DegreesToRadians(sunlong);
            double beta       = AASSun.GeometricEclipticLatitude(JD, bHighPrecision);
            double betarad    = AASCoordinateTransformation.DegreesToRadians(beta);
            double R          = AASEarth.RadiusVector(JD, bHighPrecision);

            //Calculate the the light travel time from Jupiter to the Earth
            double DELTA = 5;
            double PreviousEarthLightTravelTime = 0;
            double EarthLightTravelTime         = AASElliptical.DistanceToLightTime(DELTA);
            double JD1      = JD - EarthLightTravelTime;
            bool   bIterate = true;
            double x;
            double y;
            double z;
            double l;
            double lrad;
            double b;
            double brad;
            double r;

            while (bIterate)
            {
                //Calculate the position of Jupiter
                l    = AASJupiter.EclipticLongitude(JD1, bHighPrecision);
                lrad = AASCoordinateTransformation.DegreesToRadians(l);
                b    = AASJupiter.EclipticLatitude(JD1, bHighPrecision);
                brad = AASCoordinateTransformation.DegreesToRadians(b);
                r    = AASJupiter.RadiusVector(JD1, bHighPrecision);

                x     = r * Math.Cos(brad) * Math.Cos(lrad) + R * Math.Cos(sunlongrad);
                y     = r * Math.Cos(brad) * Math.Sin(lrad) + R * Math.Sin(sunlongrad);
                z     = r * Math.Sin(brad) + R * Math.Sin(betarad);
                DELTA = Math.Sqrt(x * x + y * y + z * z);
                EarthLightTravelTime = AASElliptical.DistanceToLightTime(DELTA);

                //Prepare for the next loop around
                bIterate = (Math.Abs(EarthLightTravelTime - PreviousEarthLightTravelTime) > 2e-6); //2e-6 corresponds to 0.17 of a second
                if (bIterate)
                {
                    JD1 = JD - EarthLightTravelTime;
                    PreviousEarthLightTravelTime = EarthLightTravelTime;
                }
            }

            //Calculate the details as seen from the earth
            AASGalileanMoonsDetails details1           = CalculateHelper(JD, sunlongrad, betarad, R, bHighPrecision);
            AASGalileanMoonDetail   details1Satellite1 = details1.Satellite1;
            AASGalileanMoonDetail   details1Satellite2 = details1.Satellite2;
            AASGalileanMoonDetail   details1Satellite3 = details1.Satellite3;
            AASGalileanMoonDetail   details1Satellite4 = details1.Satellite4;

            FillInPhenomenaDetails(ref details1Satellite1);
            FillInPhenomenaDetails(ref details1Satellite2);
            FillInPhenomenaDetails(ref details1Satellite3);
            FillInPhenomenaDetails(ref details1Satellite4);

            //Calculate the the light travel time from Jupiter to the Sun
            JD1   = JD - EarthLightTravelTime;
            l     = AASJupiter.EclipticLongitude(JD1, bHighPrecision);
            lrad  = AASCoordinateTransformation.DegreesToRadians(l);
            b     = AASJupiter.EclipticLatitude(JD1, bHighPrecision);
            brad  = AASCoordinateTransformation.DegreesToRadians(b);
            r     = AASJupiter.RadiusVector(JD1, bHighPrecision);
            x     = r * Math.Cos(brad) * Math.Cos(lrad);
            y     = r * Math.Cos(brad) * Math.Sin(lrad);
            z     = r * Math.Sin(brad);
            DELTA = Math.Sqrt(x * x + y * y + z * z);
            double SunLightTravelTime = AASElliptical.DistanceToLightTime(DELTA);

            //Calculate the details as seen from the Sun
            AASGalileanMoonsDetails details2           = CalculateHelper(JD + SunLightTravelTime - EarthLightTravelTime, sunlongrad, betarad, 0, bHighPrecision);
            AASGalileanMoonDetail   details2Satellite1 = details2.Satellite1;
            AASGalileanMoonDetail   details2Satellite2 = details2.Satellite2;
            AASGalileanMoonDetail   details2Satellite3 = details2.Satellite3;
            AASGalileanMoonDetail   details2Satellite4 = details2.Satellite4;

            FillInPhenomenaDetails(ref details2Satellite1);
            FillInPhenomenaDetails(ref details2Satellite2);
            FillInPhenomenaDetails(ref details2Satellite3);
            FillInPhenomenaDetails(ref details2Satellite4);

            //Finally transfer the required values from details2 to details1
            details1.Satellite1.bInEclipse       = details2.Satellite1.bInOccultation;
            details1.Satellite2.bInEclipse       = details2.Satellite2.bInOccultation;
            details1.Satellite3.bInEclipse       = details2.Satellite3.bInOccultation;
            details1.Satellite4.bInEclipse       = details2.Satellite4.bInOccultation;
            details1.Satellite1.bInShadowTransit = details2.Satellite1.bInTransit;
            details1.Satellite2.bInShadowTransit = details2.Satellite2.bInTransit;
            details1.Satellite3.bInShadowTransit = details2.Satellite3.bInTransit;
            details1.Satellite4.bInShadowTransit = details2.Satellite4.bInTransit;

            return(details1);
        }
Exemple #11
0
        public static AASEllipticalPlanetaryDetails Calculate(double JD, AASEllipticalObject ellipticalObject, bool bHighPrecision)
        {
            //What will the the return value
            AASEllipticalPlanetaryDetails details = new AASEllipticalPlanetaryDetails();

            //Calculate the position of the earth first
            double JD0 = JD;
            double L0  = AASEarth.EclipticLongitude(JD0, bHighPrecision);
            double B0  = AASEarth.EclipticLatitude(JD0, bHighPrecision);
            double R0  = AASEarth.RadiusVector(JD0, bHighPrecision);

            L0 = AASCoordinateTransformation.DegreesToRadians(L0);
            B0 = AASCoordinateTransformation.DegreesToRadians(B0);
            double cosB0 = Math.Cos(B0);

            //Iterate to find the positions adjusting for light-time correction if required
            double L = 0;
            double B = 0;
            double R = 0;

            if (ellipticalObject != AASEllipticalObject.SUN)
            {
                bool   bRecalc      = true;
                bool   bFirstRecalc = true;
                double LPrevious    = 0;
                double BPrevious    = 0;
                double RPrevious    = 0;

                while (bRecalc)
                {
                    switch (ellipticalObject)
                    {
                    case AASEllipticalObject.SUN:

                        L = AASSun.GeometricEclipticLongitude(JD0, bHighPrecision);
                        B = AASSun.GeometricEclipticLatitude(JD0, bHighPrecision);
                        R = AASEarth.RadiusVector(JD0, bHighPrecision);
                        break;

                    case AASEllipticalObject.MERCURY:

                        L = AASMercury.EclipticLongitude(JD0, bHighPrecision);
                        B = AASMercury.EclipticLatitude(JD0, bHighPrecision);
                        R = AASMercury.RadiusVector(JD0, bHighPrecision);
                        break;

                    case AASEllipticalObject.VENUS:

                        L = AASVenus.EclipticLongitude(JD0, bHighPrecision);
                        B = AASVenus.EclipticLatitude(JD0, bHighPrecision);
                        R = AASVenus.RadiusVector(JD0, bHighPrecision);
                        break;

                    case AASEllipticalObject.MARS:

                        L = AASMars.EclipticLongitude(JD0, bHighPrecision);
                        B = AASMars.EclipticLatitude(JD0, bHighPrecision);
                        R = AASMars.RadiusVector(JD0, bHighPrecision);
                        break;

                    case AASEllipticalObject.JUPITER:

                        L = AASJupiter.EclipticLongitude(JD0, bHighPrecision);
                        B = AASJupiter.EclipticLatitude(JD0, bHighPrecision);
                        R = AASJupiter.RadiusVector(JD0, bHighPrecision);
                        break;

                    case AASEllipticalObject.SATURN:

                        L = AASSaturn.EclipticLongitude(JD0, bHighPrecision);
                        B = AASSaturn.EclipticLatitude(JD0, bHighPrecision);
                        R = AASSaturn.RadiusVector(JD0, bHighPrecision);
                        break;

                    case AASEllipticalObject.URANUS:

                        L = AASUranus.EclipticLongitude(JD0, bHighPrecision);
                        B = AASUranus.EclipticLatitude(JD0, bHighPrecision);
                        R = AASUranus.RadiusVector(JD0, bHighPrecision);
                        break;

                    case AASEllipticalObject.NEPTUNE:

                        L = AASNeptune.EclipticLongitude(JD0, bHighPrecision);
                        B = AASNeptune.EclipticLatitude(JD0, bHighPrecision);
                        R = AASNeptune.RadiusVector(JD0, bHighPrecision);
                        break;

                    case AASEllipticalObject.PLUTO:

                        L = AASPluto.EclipticLongitude(JD0);
                        B = AASPluto.EclipticLatitude(JD0);
                        R = AASPluto.RadiusVector(JD0);
                        break;

                    default:
                        break;
                    }

                    if (!bFirstRecalc)
                    {
                        bRecalc   = ((Math.Abs(L - LPrevious) > 0.00001) || (Math.Abs(B - BPrevious) > 0.00001) || (Math.Abs(R - RPrevious) > 0.000001));
                        LPrevious = L;
                        BPrevious = B;
                        RPrevious = R;
                    }
                    else
                    {
                        bFirstRecalc = false;
                    }

                    //Calculate the new value
                    if (bRecalc)
                    {
                        double Lrad     = AASCoordinateTransformation.DegreesToRadians(L);
                        double Brad     = AASCoordinateTransformation.DegreesToRadians(B);
                        double cosB     = Math.Cos(Brad);
                        double cosL     = Math.Cos(Lrad);
                        double x1       = R * cosB * cosL - R0 * cosB0 * Math.Cos(L0);
                        double y1       = R * cosB * Math.Sin(Lrad) - R0 * cosB0 * Math.Sin(L0);
                        double z1       = R * Math.Sin(Brad) - R0 * Math.Sin(B0);
                        double distance = Math.Sqrt(x1 * x1 + y1 * y1 + z1 * z1);

                        //Prepare for the next loop around
                        JD0 = JD - AASElliptical.DistanceToLightTime(distance);
                    }
                }
            }

            double x = 0;
            double y = 0;
            double z = 0;

            if (ellipticalObject != AASEllipticalObject.SUN)
            {
                double Lrad = AASCoordinateTransformation.DegreesToRadians(L);
                double Brad = AASCoordinateTransformation.DegreesToRadians(B);
                double cosB = Math.Cos(Brad);
                double cosL = Math.Cos(Lrad);

                x = R * cosB * cosL - R0 * cosB0 * Math.Cos(L0);
                y = R * cosB * Math.Sin(Lrad) - R0 * cosB0 * Math.Sin(L0);
                z = R * Math.Sin(Brad) - R0 * Math.Sin(B0);
            }
            else
            {
                x = -R0 *cosB0 *Math.Cos(L0);

                y = -R0 *cosB0 *Math.Sin(L0);

                z = -R0 *Math.Sin(B0);
            }

            double x2 = x * x;
            double y2 = y * y;

            details.ApparentGeocentricLatitude  = AASCoordinateTransformation.RadiansToDegrees(Math.Atan2(z, Math.Sqrt(x2 + y2)));
            details.ApparentGeocentricDistance  = Math.Sqrt(x2 + y2 + z * z);
            details.ApparentGeocentricLongitude = AASCoordinateTransformation.MapTo0To360Range(AASCoordinateTransformation.RadiansToDegrees(Math.Atan2(y, x)));
            details.ApparentLightTime           = AASElliptical.DistanceToLightTime(details.ApparentGeocentricDistance);

            //Adjust for Aberration
            AAS2DCoordinate Aberration = AASAberration.EclipticAberration(details.ApparentGeocentricLongitude, details.ApparentGeocentricLatitude, JD, bHighPrecision);

            details.ApparentGeocentricLongitude += Aberration.X;
            details.ApparentGeocentricLatitude  += Aberration.Y;

            //convert to the FK5 system
            double DeltaLong = AASFK5.CorrectionInLongitude(details.ApparentGeocentricLongitude, details.ApparentGeocentricLatitude, JD);

            details.ApparentGeocentricLatitude  += AASFK5.CorrectionInLatitude(details.ApparentGeocentricLongitude, JD);
            details.ApparentGeocentricLongitude += DeltaLong;

            //Correct for nutation
            double NutationInLongitude = AASNutation.NutationInLongitude(JD);
            double Epsilon             = AASNutation.TrueObliquityOfEcliptic(JD);

            details.ApparentGeocentricLongitude += AASCoordinateTransformation.DMSToDegrees(0, 0, NutationInLongitude);

            //Convert to RA and Dec
            AAS2DCoordinate ApparentEqu = AASCoordinateTransformation.Ecliptic2Equatorial(details.ApparentGeocentricLongitude, details.ApparentGeocentricLatitude, Epsilon);

            details.ApparentGeocentricRA          = ApparentEqu.X;
            details.ApparentGeocentricDeclination = ApparentEqu.Y;

            return(details);
        }