public void TheoryTest(double JD, bool bHighPrecision, CAAPhysicalJupiterDetails expectedJupiterDetails)
        {
            CAAPhysicalJupiterDetails jupiterDetails = AASPhysicalJupiter.Calculate(JD, bHighPrecision);

            Assert.Equal(expectedJupiterDetails.DE, jupiterDetails.DE);
            Assert.Equal(expectedJupiterDetails.DS, jupiterDetails.DS);
            Assert.Equal(expectedJupiterDetails.Geometricw1, jupiterDetails.Geometricw1);
            Assert.Equal(expectedJupiterDetails.Geometricw2, jupiterDetails.Geometricw2);
            Assert.Equal(expectedJupiterDetails.Apparentw1, jupiterDetails.Apparentw1);
            Assert.Equal(expectedJupiterDetails.Apparentw2, jupiterDetails.Apparentw2);
            Assert.Equal(expectedJupiterDetails.P, jupiterDetails.P);
        }
//Static methods

    //////////////////////////////// Implementation ///////////////////////////////

    public static CAAPhysicalJupiterDetails Calculate(double JD)
    {
        //What will be the return value
        CAAPhysicalJupiterDetails details = new CAAPhysicalJupiterDetails();

        //Step 1
        double d         = JD - 2433282.5;
        double T1        = d / 36525;
        double alpha0    = 268.00 + 0.1061 * T1;
        double alpha0rad = CT.D2R(alpha0);
        double delta0    = 64.50 - 0.0164 * T1;
        double delta0rad = CT.D2R(delta0);

        //Step 2
        double W1 = CT.M360(17.710 + 877.90003539 * d);
        double W2 = CT.M360(16.838 + 870.27003539 * d);

        //Step 3
        double l0    = CAAEarth.EclipticLongitude(JD);
        double l0rad = CT.D2R(l0);
        double b0    = CAAEarth.EclipticLatitude(JD);
        double b0rad = CT.D2R(b0);
        double R     = CAAEarth.RadiusVector(JD);

        //Step 4
        double l    = CAAJupiter.EclipticLongitude(JD);
        double lrad = CT.D2R(l);
        double b    = CAAJupiter.EclipticLatitude(JD);
        double brad = CT.D2R(b);
        double r    = CAAJupiter.RadiusVector(JD);

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

        //Step 6
        l   -= 0.012990 * DELTA / (r * r);
        lrad = CT.D2R(l);

        //Step 7
        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);

        //Step 8
        double e0    = CAANutation.MeanObliquityOfEcliptic(JD);
        double e0rad = CT.D2R(e0);

        //Step 9
        double alphas = Math.Atan2(Math.Cos(e0rad) * Math.Sin(lrad) - Math.Sin(e0rad) * Math.Tan(brad), Math.Cos(lrad));
        double deltas = Math.Asin(Math.Cos(e0rad) * Math.Sin(brad) + Math.Sin(e0rad) * Math.Cos(brad) * Math.Sin(lrad));

        //Step 10
        details.DS = CT.R2D(Math.Asin(-Math.Sin(delta0rad) * Math.Sin(deltas) - Math.Cos(delta0rad) * Math.Cos(deltas) * Math.Cos(alpha0rad - alphas)));

        //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    = CT.R2D(alpharad);
        double deltarad = Math.Atan2(v, Math.Sqrt(x * x + u * u));
        double delta    = CT.R2D(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.DE = CT.R2D(Math.Asin(-Math.Sin(delta0rad) * Math.Sin(deltarad) - Math.Cos(delta0rad) * Math.Cos(deltarad) * Math.Cos(alpha0rad - alpharad)));

        //Step 13
        details.Geometricw1 = CT.M360(W1 - CT.R2D(xi) - 5.07033 * DELTA);
        details.Geometricw2 = CT.M360(W2 - CT.R2D(xi) - 5.02626 * DELTA);

        //Step 14
        double C = 57.2958 * (2 * r * DELTA + R * R - r * r - DELTA * DELTA) / (4 * r * DELTA);

        if (Math.Sin(lrad - l0rad) > 0)
        {
            details.Apparentw1 = CT.M360(details.Geometricw1 + C);
            details.Apparentw2 = CT.M360(details.Geometricw2 + C);
        }
        else
        {
            details.Apparentw1 = CT.M360(details.Geometricw1 - C);
            details.Apparentw2 = CT.M360(details.Geometricw2 - C);
        }

        //Step 15
        double NutationInLongitude = CAANutation.NutationInLongitude(JD);
        double NutationInObliquity = CAANutation.NutationInObliquity(JD);

        e0   += NutationInObliquity / 3600;
        e0rad = CT.D2R(e0);

        //Step 16
        alpha   += 0.005693 * (Math.Cos(alpharad) * Math.Cos(l0rad) * Math.Cos(e0rad) + Math.Sin(alpharad) * Math.Sin(l0rad)) / Math.Cos(deltarad);
        alpha    = CT.M360(alpha);
        alpharad = CT.D2R(alpha);
        delta   += 0.005693 * (Math.Cos(l0rad) * Math.Cos(e0rad) * (Math.Tan(e0rad) * Math.Cos(deltarad) - Math.Sin(alpharad) * Math.Sin(deltarad)) + Math.Cos(alpharad) * Math.Sin(deltarad) * Math.Sin(l0rad));
        deltarad = CT.D2R(delta);

        //Step 17
        double NutationRA   = CAANutation.NutationInRightAscension(alpha / 15, delta, e0, NutationInLongitude, NutationInObliquity);
        double alphadash    = alpha + NutationRA / 3600;
        double alphadashrad = CT.D2R(alphadash);
        double NutationDec  = CAANutation.NutationInDeclination(alpha / 15, delta, e0, NutationInLongitude, NutationInObliquity);
        double deltadash    = delta + NutationDec / 3600;
        double deltadashrad = CT.D2R(deltadash);

        NutationRA = CAANutation.NutationInRightAscension(alpha0 / 15, delta0, e0, NutationInLongitude, NutationInObliquity);
        double alpha0dash    = alpha0 + NutationRA / 3600;
        double alpha0dashrad = CT.D2R(alpha0dash);

        NutationDec = CAANutation.NutationInDeclination(alpha0 / 15, delta0, e0, NutationInLongitude, NutationInObliquity);
        double delta0dash    = delta0 + NutationDec / 3600;
        double delta0dashrad = CT.D2R(delta0dash);

        //Step 18
        details.P = CT.M360(CT.R2D(Math.Atan2(Math.Cos(delta0dashrad) * Math.Sin(alpha0dashrad - alphadashrad), Math.Sin(delta0dashrad) * Math.Cos(deltadashrad) - Math.Cos(delta0dashrad) * Math.Sin(deltadashrad) * Math.Cos(alpha0dashrad - alphadashrad))));

        return(details);
    }
        public static AstroRaDec GetPlanet(double jDate, EO planetIn, double locLat, double locLong, double locHeight)
        {
            int planet = (int)planetIn;

//C++ TO C# CONVERTER NOTE: This static local variable declaration (not allowed in C#) has been moved just prior to the method:
//			static CAAGalileanMoonsDetails galDetails;
//C++ TO C# CONVERTER NOTE: This static local variable declaration (not allowed in C#) has been moved just prior to the method:
//			static CAAEllipticalPlanetaryDetails jupDetails;
//C++ TO C# CONVERTER NOTE: This static local variable declaration (not allowed in C#) has been moved just prior to the method:
//			static CAAPhysicalJupiterDetails jupPhisical;
//C++ TO C# CONVERTER NOTE: This static local variable declaration (not allowed in C#) has been moved just prior to the method:
//			static double jDateLast = 0;

            locLong = -locLong;
            if (planet < 9)
            {
                EPD Details   = ELL.Calculate(jDate, planetIn);
                COR corrected = CAAParallax.Equatorial2Topocentric(Details.ApparentGeocentricRA, Details.ApparentGeocentricDeclination, Details.ApparentGeocentricDistance, locLong, locLat, locHeight, jDate);
                return(new AstroRaDec(corrected.X, corrected.Y, Details.ApparentGeocentricDistance, false, false));
            }
            else if (planet == 9)
            {
                double lat       = CAAMoon.EclipticLatitude(jDate);
                double lng       = CAAMoon.EclipticLongitude(jDate);
                double dis       = CAAMoon.RadiusVector(jDate) / 149598000;
                double epsilon   = CAANutation.TrueObliquityOfEcliptic(jDate);
                COR    d         = CT.Ec2Eq(lng, lat, epsilon);
                COR    corrected = CAAParallax.Equatorial2Topocentric(d.X, d.Y, dis, locLong, locLat, locHeight, jDate);

                return(new AstroRaDec(corrected.X, corrected.Y, dis, false, false));
            }
            else
            {
                if (jDate != jDateLast)
                {
                    jupDetails  = ELL.Calculate(jDate, (EO)4);
                    jupPhisical = CAAPhysicalJupiter.Calculate(jDate);
                    COR corrected = CAAParallax.Equatorial2Topocentric(jupDetails.ApparentGeocentricRA, jupDetails.ApparentGeocentricDeclination, jupDetails.ApparentGeocentricDistance, locLong, locLat, locHeight, jDate);
                    jupDetails.ApparentGeocentricRA          = corrected.X;
                    jupDetails.ApparentGeocentricDeclination = corrected.Y;
                    galDetails = GM.Calculate(jDate);
                    jDateLast  = jDate;
                }


                double jupiterDiameter = 0.000954501;
                double scale           = (Math.Atan(.5 * (jupiterDiameter / jupDetails.ApparentGeocentricDistance))) / 3.1415927 * 180;

                double raScale = (scale / Math.Cos(jupDetails.ApparentGeocentricDeclination / 180.0 * 3.1415927)) / 15;

                double xMoon    = 0;
                double yMoon    = 0;
                double zMoon    = 0;
                bool   shadow   = false;
                bool   eclipsed = false;

                switch (planet)
                {
                case 10:                         // IO
                    xMoon    = galDetails.Satellite1.ApparentRectangularCoordinates.X;
                    yMoon    = galDetails.Satellite1.ApparentRectangularCoordinates.Y;
                    zMoon    = galDetails.Satellite1.ApparentRectangularCoordinates.Z;
                    eclipsed = galDetails.Satellite1.bInEclipse;
                    shadow   = galDetails.Satellite1.bInShadowTransit;
                    break;

                case 11:                         //Europa
                    xMoon    = galDetails.Satellite2.ApparentRectangularCoordinates.X;
                    yMoon    = galDetails.Satellite2.ApparentRectangularCoordinates.Y;
                    zMoon    = galDetails.Satellite2.ApparentRectangularCoordinates.Z;
                    eclipsed = galDetails.Satellite2.bInEclipse;
                    shadow   = galDetails.Satellite2.bInShadowTransit;
                    break;

                case 12:                         //Ganymede
                    xMoon    = galDetails.Satellite3.ApparentRectangularCoordinates.X;
                    yMoon    = galDetails.Satellite3.ApparentRectangularCoordinates.Y;
                    zMoon    = galDetails.Satellite3.ApparentRectangularCoordinates.Z;
                    eclipsed = galDetails.Satellite3.bInEclipse;
                    shadow   = galDetails.Satellite3.bInShadowTransit;
                    break;

                case 13:                         //Callisto
                    xMoon    = galDetails.Satellite4.ApparentRectangularCoordinates.X;
                    yMoon    = galDetails.Satellite4.ApparentRectangularCoordinates.Y;
                    zMoon    = galDetails.Satellite4.ApparentRectangularCoordinates.Z;
                    eclipsed = galDetails.Satellite4.bInEclipse;
                    shadow   = galDetails.Satellite4.bInShadowTransit;
                    break;

                case 14:                         // IO Shadow
                    xMoon  = galDetails.Satellite1.ApparentShadowRectangularCoordinates.X;
                    yMoon  = galDetails.Satellite1.ApparentShadowRectangularCoordinates.Y;
                    zMoon  = galDetails.Satellite1.ApparentShadowRectangularCoordinates.Z * .9;
                    shadow = galDetails.Satellite1.bInShadowTransit;
                    break;

                case 15:                         //Europa Shadow
                    xMoon  = galDetails.Satellite2.ApparentShadowRectangularCoordinates.X;
                    yMoon  = galDetails.Satellite2.ApparentShadowRectangularCoordinates.Y;
                    zMoon  = galDetails.Satellite2.ApparentShadowRectangularCoordinates.Z * .9;
                    shadow = galDetails.Satellite2.bInShadowTransit;
                    break;

                case 16:                         //Ganymede Shadow
                    xMoon  = galDetails.Satellite3.ApparentShadowRectangularCoordinates.X;
                    yMoon  = galDetails.Satellite3.ApparentShadowRectangularCoordinates.Y;
                    zMoon  = galDetails.Satellite3.ApparentShadowRectangularCoordinates.Z * .9;
                    shadow = galDetails.Satellite3.bInShadowTransit;
                    break;

                case 17:                         //Callisto Shadow
                    xMoon  = galDetails.Satellite4.ApparentShadowRectangularCoordinates.X;
                    yMoon  = galDetails.Satellite4.ApparentShadowRectangularCoordinates.Y;
                    zMoon  = galDetails.Satellite4.ApparentShadowRectangularCoordinates.Z * .9;
                    shadow = galDetails.Satellite4.bInShadowTransit;
                    break;
                }

                double xTemp;
                double yTemp;
                double radians = jupPhisical.P / 180.0 * 3.1415927;
                xTemp = xMoon * Math.Cos(radians) - yMoon * Math.Sin(radians);
                yTemp = xMoon * Math.Sin(radians) + yMoon * Math.Cos(radians);
                xMoon = xTemp;
                yMoon = yTemp;

                return(new AstroRaDec(jupDetails.ApparentGeocentricRA - (xMoon * raScale), jupDetails.ApparentGeocentricDeclination + yMoon * scale, jupDetails.ApparentGeocentricDistance + (zMoon * jupiterDiameter / 2), shadow, eclipsed));
            }
        }
Esempio n. 4
0
        public static AstroRaDec GetPlanet(double jDate, int planet, double locLat, double locLong, double locHeight)
        {
            locLong = -locLong;
            if (planet < 9)
            {
                var Details = CAAElliptical.Calculate(jDate, (EllipticalObject) planet);
                var corrected = CAAParallax.Equatorial2Topocentric(Details.ApparentGeocentricRA, Details.ApparentGeocentricDeclination, Details.ApparentGeocentricDistance, locLong, locLat, locHeight, jDate);
                return new AstroRaDec(corrected.X, corrected.Y, Details.ApparentGeocentricDistance, false, false);
            }
            if (planet == 9)
            {
                var lat = CAAMoon.EclipticLatitude(jDate);
                var lng = CAAMoon.EclipticLongitude(jDate);
                var dis = CAAMoon.RadiusVector(jDate)/149598000;
                var epsilon = CAANutation.TrueObliquityOfEcliptic(jDate);
                var d = CAACoordinateTransformation.Ecliptic2Equatorial(lng, lat, epsilon);
                var corrected = CAAParallax.Equatorial2Topocentric(d.X, d.Y, dis, locLong, locLat, locHeight, jDate);

                return new AstroRaDec(corrected.X, corrected.Y, dis, false, false);

            }
            if (jDate != jDateLast)
            {
                jupDetails = CAAElliptical.Calculate(jDate, (EllipticalObject) 4);
                jupPhisical = CAAPhysicalJupiter.Calculate(jDate);
                var corrected = CAAParallax.Equatorial2Topocentric(jupDetails.ApparentGeocentricRA, jupDetails.ApparentGeocentricDeclination, jupDetails.ApparentGeocentricDistance, locLong, locLat, locHeight, jDate);
                jupDetails.ApparentGeocentricRA = corrected.X;
                jupDetails.ApparentGeocentricDeclination = corrected.Y;
                galDetails = CAAGalileanMoons.Calculate(jDate);
                jDateLast = jDate;
            }

            const double jupiterDiameter = 0.000954501;
            var scale = (Math.Atan(.5 * (jupiterDiameter / jupDetails.ApparentGeocentricDistance))) / 3.1415927 * 180;

            var raScale = (scale / Math.Cos(jupDetails.ApparentGeocentricDeclination / 180.0 * 3.1415927))/15;

            double xMoon=0;
            double yMoon=0;
            double zMoon=0;
            var shadow = false;
            var eclipsed = false;

            switch (planet)
            {
                case 10: // IO
                    xMoon = galDetails.Satellite1.ApparentRectangularCoordinates.X;
                    yMoon = galDetails.Satellite1.ApparentRectangularCoordinates.Y;
                    zMoon = galDetails.Satellite1.ApparentRectangularCoordinates.Z;
                    eclipsed = galDetails.Satellite1.bInEclipse;
                    shadow = galDetails.Satellite1.bInShadowTransit;
                    break;
                case 11: //Europa
                    xMoon = galDetails.Satellite2.ApparentRectangularCoordinates.X;
                    yMoon = galDetails.Satellite2.ApparentRectangularCoordinates.Y;
                    zMoon = galDetails.Satellite2.ApparentRectangularCoordinates.Z;
                    eclipsed = galDetails.Satellite2.bInEclipse;
                    shadow = galDetails.Satellite2.bInShadowTransit;
                    break;
                case 12: //Ganymede
                    xMoon = galDetails.Satellite3.ApparentRectangularCoordinates.X;
                    yMoon = galDetails.Satellite3.ApparentRectangularCoordinates.Y;
                    zMoon = galDetails.Satellite3.ApparentRectangularCoordinates.Z;
                    eclipsed = galDetails.Satellite3.bInEclipse;
                    shadow = galDetails.Satellite3.bInShadowTransit;
                    break;
                case 13: //Callisto
                    xMoon = galDetails.Satellite4.ApparentRectangularCoordinates.X;
                    yMoon = galDetails.Satellite4.ApparentRectangularCoordinates.Y;
                    zMoon = galDetails.Satellite4.ApparentRectangularCoordinates.Z;
                    eclipsed = galDetails.Satellite4.bInEclipse;
                    shadow = galDetails.Satellite4.bInShadowTransit;
                    break;
                case 14: // IO Shadow
                    xMoon = galDetails.Satellite1.ApparentShadowRectangularCoordinates.X;
                    yMoon = galDetails.Satellite1.ApparentShadowRectangularCoordinates.Y;
                    zMoon = galDetails.Satellite1.ApparentShadowRectangularCoordinates.Z*.9;
                    shadow = galDetails.Satellite1.bInShadowTransit;
                    break;
                case 15: //Europa Shadow
                    xMoon = galDetails.Satellite2.ApparentShadowRectangularCoordinates.X;
                    yMoon = galDetails.Satellite2.ApparentShadowRectangularCoordinates.Y;
                    zMoon = galDetails.Satellite2.ApparentShadowRectangularCoordinates.Z*.9;
                    shadow = galDetails.Satellite2.bInShadowTransit;
                    break;
                case 16: //Ganymede Shadow
                    xMoon = galDetails.Satellite3.ApparentShadowRectangularCoordinates.X;
                    yMoon = galDetails.Satellite3.ApparentShadowRectangularCoordinates.Y;
                    zMoon = galDetails.Satellite3.ApparentShadowRectangularCoordinates.Z*.9;
                    shadow = galDetails.Satellite3.bInShadowTransit;
                    break;
                case 17: //Callisto Shadow
                    xMoon = galDetails.Satellite4.ApparentShadowRectangularCoordinates.X;
                    yMoon = galDetails.Satellite4.ApparentShadowRectangularCoordinates.Y;
                    zMoon = galDetails.Satellite4.ApparentShadowRectangularCoordinates.Z*.9;
                    shadow = galDetails.Satellite4.bInShadowTransit;
                    break;
            }

            var radians = jupPhisical.P /180.0 * 3.1415927;
            double xTemp = xMoon * Math.Cos(radians) - yMoon * Math.Sin(radians);
            double yTemp = xMoon * Math.Sin(radians) + yMoon * Math.Cos(radians);
            xMoon = xTemp;
            yMoon = yTemp;

            return new AstroRaDec(jupDetails.ApparentGeocentricRA - (xMoon * raScale), jupDetails.ApparentGeocentricDeclination + yMoon * scale, jupDetails.ApparentGeocentricDistance + (zMoon *jupiterDiameter/2), shadow, eclipsed);
        }
    //Static methods
    //////////////////////////////// Implementation ///////////////////////////////
    public static CAAPhysicalJupiterDetails Calculate(double JD)
    {
        //What will be the return value
        CAAPhysicalJupiterDetails details = new CAAPhysicalJupiterDetails();

        //Step 1
        double d = JD - 2433282.5;
        double T1 = d/36525;
        double alpha0 = 268.00 + 0.1061 *T1;
        double alpha0rad = CT.D2R(alpha0);
        double delta0 = 64.50 - 0.0164 *T1;
        double delta0rad = CT.D2R(delta0);

        //Step 2
        double W1 = CT.M360(17.710 + 877.90003539 *d);
        double W2 = CT.M360(16.838 + 870.27003539 *d);

        //Step 3
        double l0 = CAAEarth.EclipticLongitude(JD);
        double l0rad = CT.D2R(l0);
        double b0 = CAAEarth.EclipticLatitude(JD);
        double b0rad = CT.D2R(b0);
        double R = CAAEarth.RadiusVector(JD);

        //Step 4
        double l = CAAJupiter.EclipticLongitude(JD);
        double lrad = CT.D2R(l);
        double b = CAAJupiter.EclipticLatitude(JD);
        double brad = CT.D2R(b);
        double r = CAAJupiter.RadiusVector(JD);

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

        //Step 6
        l -= 0.012990 *DELTA/(r *r);
        lrad = CT.D2R(l);

        //Step 7
        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);

        //Step 8
        double e0 = CAANutation.MeanObliquityOfEcliptic(JD);
        double e0rad = CT.D2R(e0);

        //Step 9
        double alphas = Math.Atan2(Math.Cos(e0rad)*Math.Sin(lrad) - Math.Sin(e0rad)*Math.Tan(brad), Math.Cos(lrad));
        double deltas = Math.Asin(Math.Cos(e0rad)*Math.Sin(brad) + Math.Sin(e0rad)*Math.Cos(brad)*Math.Sin(lrad));

        //Step 10
        details.DS = CT.R2D(Math.Asin(-Math.Sin(delta0rad)*Math.Sin(deltas) - Math.Cos(delta0rad)*Math.Cos(deltas)*Math.Cos(alpha0rad - alphas)));

        //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 = CT.R2D(alpharad);
        double deltarad = Math.Atan2(v, Math.Sqrt(x *x + u *u));
        double delta = CT.R2D(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.DE = CT.R2D(Math.Asin(-Math.Sin(delta0rad)*Math.Sin(deltarad) - Math.Cos(delta0rad)*Math.Cos(deltarad)*Math.Cos(alpha0rad - alpharad)));

        //Step 13
        details.Geometricw1 = CT.M360(W1 - CT.R2D(xi) - 5.07033 *DELTA);
        details.Geometricw2 = CT.M360(W2 - CT.R2D(xi) - 5.02626 *DELTA);

        //Step 14
        double C = 57.2958 * (2 *r *DELTA + R *R - r *r - DELTA *DELTA)/(4 *r *DELTA);
        if (Math.Sin(lrad - l0rad) > 0)
        {
          details.Apparentw1 = CT.M360(details.Geometricw1 + C);
          details.Apparentw2 = CT.M360(details.Geometricw2 + C);
        }
        else
        {
          details.Apparentw1 = CT.M360(details.Geometricw1 - C);
          details.Apparentw2 = CT.M360(details.Geometricw2 - C);
        }

        //Step 15
        double NutationInLongitude = CAANutation.NutationInLongitude(JD);
        double NutationInObliquity = CAANutation.NutationInObliquity(JD);
        e0 += NutationInObliquity/3600;
        e0rad = CT.D2R(e0);

        //Step 16
        alpha += 0.005693*(Math.Cos(alpharad)*Math.Cos(l0rad)*Math.Cos(e0rad) + Math.Sin(alpharad)*Math.Sin(l0rad))/Math.Cos(deltarad);
        alpha = CT.M360(alpha);
        alpharad = CT.D2R(alpha);
        delta += 0.005693*(Math.Cos(l0rad)*Math.Cos(e0rad)*(Math.Tan(e0rad)*Math.Cos(deltarad) - Math.Sin(alpharad)*Math.Sin(deltarad)) + Math.Cos(alpharad)*Math.Sin(deltarad)*Math.Sin(l0rad));
        deltarad = CT.D2R(delta);

        //Step 17
        double NutationRA = CAANutation.NutationInRightAscension(alpha/15, delta, e0, NutationInLongitude, NutationInObliquity);
        double alphadash = alpha + NutationRA/3600;
        double alphadashrad = CT.D2R(alphadash);
        double NutationDec = CAANutation.NutationInDeclination(alpha/15, delta, e0, NutationInLongitude, NutationInObliquity);
        double deltadash = delta + NutationDec/3600;
        double deltadashrad = CT.D2R(deltadash);
        NutationRA = CAANutation.NutationInRightAscension(alpha0/15, delta0, e0, NutationInLongitude, NutationInObliquity);
        double alpha0dash = alpha0 + NutationRA/3600;
        double alpha0dashrad = CT.D2R(alpha0dash);
        NutationDec = CAANutation.NutationInDeclination(alpha0/15, delta0, e0, NutationInLongitude, NutationInObliquity);
        double delta0dash = delta0 + NutationDec/3600;
        double delta0dashrad = CT.D2R(delta0dash);

        //Step 18
        details.P = CT.M360(CT.R2D(Math.Atan2(Math.Cos(delta0dashrad)*Math.Sin(alpha0dashrad - alphadashrad), Math.Sin(delta0dashrad)*Math.Cos(deltadashrad) - Math.Cos(delta0dashrad)*Math.Sin(deltadashrad)*Math.Cos(alpha0dashrad - alphadashrad))));

        return details;
    }
Esempio n. 6
0
        public static AstroRaDec GetPlanet(double jDate, EO planetIn, double locLat, double locLong, double locHeight)
        {
            int planet = (int)planetIn;
            //C++ TO C# CONVERTER NOTE: This static local variable declaration (not allowed in C#) has been moved just prior to the method:
            //			static CAAGalileanMoonsDetails galDetails;
            //C++ TO C# CONVERTER NOTE: This static local variable declaration (not allowed in C#) has been moved just prior to the method:
            //			static CAAEllipticalPlanetaryDetails jupDetails;
            //C++ TO C# CONVERTER NOTE: This static local variable declaration (not allowed in C#) has been moved just prior to the method:
            //			static CAAPhysicalJupiterDetails jupPhisical;
            //C++ TO C# CONVERTER NOTE: This static local variable declaration (not allowed in C#) has been moved just prior to the method:
            //			static double jDateLast = 0;

            locLong = -locLong;
            if (planet < 9)
            {
                EPD Details = ELL.Calculate(jDate, planetIn);
                COR corrected = CAAParallax.Equatorial2Topocentric(Details.ApparentGeocentricRA, Details.ApparentGeocentricDeclination, Details.ApparentGeocentricDistance, locLong, locLat, locHeight, jDate);
                return new AstroRaDec(corrected.X, corrected.Y, Details.ApparentGeocentricDistance, false, false);
            }
            else if (planet == 9)
            {
                double lat = CAAMoon.EclipticLatitude(jDate);
                double lng = CAAMoon.EclipticLongitude(jDate);
                double dis = CAAMoon.RadiusVector(jDate)/149598000;
                double epsilon = CAANutation.TrueObliquityOfEcliptic(jDate);
                COR d = CT.Ec2Eq(lng, lat, epsilon);
                COR corrected = CAAParallax.Equatorial2Topocentric(d.X, d.Y, dis, locLong, locLat, locHeight, jDate);

                return new AstroRaDec(corrected.X, corrected.Y, dis, false, false);

            }
            else
            {
                if (jDate != jDateLast)
                {
                    jupDetails = ELL.Calculate(jDate, (EO) 4);
                    jupPhisical = CAAPhysicalJupiter.Calculate(jDate);
                    COR corrected = CAAParallax.Equatorial2Topocentric(jupDetails.ApparentGeocentricRA, jupDetails.ApparentGeocentricDeclination, jupDetails.ApparentGeocentricDistance, locLong, locLat, locHeight, jDate);
                    jupDetails.ApparentGeocentricRA = corrected.X;
                    jupDetails.ApparentGeocentricDeclination = corrected.Y;
                    galDetails = GM.Calculate(jDate);
                    jDateLast = jDate;
                }

                double jupiterDiameter = 0.000954501;
                double scale = (Math.Atan(.5 * (jupiterDiameter / jupDetails.ApparentGeocentricDistance))) / 3.1415927 * 180;

                double raScale = (scale / Math.Cos(jupDetails.ApparentGeocentricDeclination / 180.0 * 3.1415927))/15;

                double xMoon=0;
                double yMoon=0;
                double zMoon=0;
                bool shadow = false;
                bool eclipsed = false;

                switch (planet)
                {
                    case 10: // IO
                        xMoon = galDetails.Satellite1.ApparentRectangularCoordinates.X;
                        yMoon = galDetails.Satellite1.ApparentRectangularCoordinates.Y;
                        zMoon = galDetails.Satellite1.ApparentRectangularCoordinates.Z;
                        eclipsed = galDetails.Satellite1.bInEclipse;
                        shadow = galDetails.Satellite1.bInShadowTransit;
                        break;
                    case 11: //Europa
                        xMoon = galDetails.Satellite2.ApparentRectangularCoordinates.X;
                        yMoon = galDetails.Satellite2.ApparentRectangularCoordinates.Y;
                        zMoon = galDetails.Satellite2.ApparentRectangularCoordinates.Z;
                        eclipsed = galDetails.Satellite2.bInEclipse;
                        shadow = galDetails.Satellite2.bInShadowTransit;
                        break;
                    case 12: //Ganymede
                        xMoon = galDetails.Satellite3.ApparentRectangularCoordinates.X;
                        yMoon = galDetails.Satellite3.ApparentRectangularCoordinates.Y;
                        zMoon = galDetails.Satellite3.ApparentRectangularCoordinates.Z;
                        eclipsed = galDetails.Satellite3.bInEclipse;
                        shadow = galDetails.Satellite3.bInShadowTransit;
                        break;
                    case 13: //Callisto
                        xMoon = galDetails.Satellite4.ApparentRectangularCoordinates.X;
                        yMoon = galDetails.Satellite4.ApparentRectangularCoordinates.Y;
                        zMoon = galDetails.Satellite4.ApparentRectangularCoordinates.Z;
                        eclipsed = galDetails.Satellite4.bInEclipse;
                        shadow = galDetails.Satellite4.bInShadowTransit;
                        break;
                    case 14: // IO Shadow
                        xMoon = galDetails.Satellite1.ApparentShadowRectangularCoordinates.X;
                        yMoon = galDetails.Satellite1.ApparentShadowRectangularCoordinates.Y;
                        zMoon = galDetails.Satellite1.ApparentShadowRectangularCoordinates.Z*.9;
                        shadow = galDetails.Satellite1.bInShadowTransit;
                        break;
                    case 15: //Europa Shadow
                        xMoon = galDetails.Satellite2.ApparentShadowRectangularCoordinates.X;
                        yMoon = galDetails.Satellite2.ApparentShadowRectangularCoordinates.Y;
                        zMoon = galDetails.Satellite2.ApparentShadowRectangularCoordinates.Z*.9;
                        shadow = galDetails.Satellite2.bInShadowTransit;
                        break;
                    case 16: //Ganymede Shadow
                        xMoon = galDetails.Satellite3.ApparentShadowRectangularCoordinates.X;
                        yMoon = galDetails.Satellite3.ApparentShadowRectangularCoordinates.Y;
                        zMoon = galDetails.Satellite3.ApparentShadowRectangularCoordinates.Z*.9;
                        shadow = galDetails.Satellite3.bInShadowTransit;
                        break;
                    case 17: //Callisto Shadow
                        xMoon = galDetails.Satellite4.ApparentShadowRectangularCoordinates.X;
                        yMoon = galDetails.Satellite4.ApparentShadowRectangularCoordinates.Y;
                        zMoon = galDetails.Satellite4.ApparentShadowRectangularCoordinates.Z*.9;
                        shadow = galDetails.Satellite4.bInShadowTransit;
                        break;
                }

                double xTemp;
                double yTemp;
                double radians = jupPhisical.P /180.0 * 3.1415927;
                xTemp = xMoon * Math.Cos(radians) - yMoon * Math.Sin(radians);
                yTemp = xMoon * Math.Sin(radians) + yMoon * Math.Cos(radians);
                xMoon = xTemp;
                yMoon = yTemp;

                return new AstroRaDec(jupDetails.ApparentGeocentricRA - (xMoon * raScale), jupDetails.ApparentGeocentricDeclination + yMoon * scale, jupDetails.ApparentGeocentricDistance + (zMoon *jupiterDiameter/2), shadow, eclipsed);

            }
        }