public static double SummerSolstice(int Year)
    {
        //calculate the approximate date
        double JDE = 0;

        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 = CAASun.ApparentEclipticLongitude(JDE);
            Correction = 58 * Math.Sin(CAACoordinateTransformation.DegreesToRadians(90 - SunLongitude));
            JDE       += Correction;
        }while (Math.Abs(Correction) > 0.00001); //Corresponds to an error of 0.86 of a second

        return(JDE);
    }
    public static double WinterSolstice(int Year)
    {
        //calculate the approximate date
        double JDE = 0;

        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 = CAASun.ApparentEclipticLongitude(JDE);
            Correction = 58 * Math.Sin(CAACoordinateTransformation.DegreesToRadians(270 - SunLongitude));
            JDE       += Correction;
        }while (Math.Abs(Correction) > 0.00001); //Corresponds to an error of 0.86 of a second

        return(JDE);
    }
//Static methods

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

    public static double SpringEquinox(int Year)
    {
        //calculate the approximate date
        double JDE = 0;

        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 = CAASun.ApparentEclipticLongitude(JDE);
            Correction = 58 * Math.Sin(CAACoordinateTransformation.DegreesToRadians(-SunLongitude));
            JDE       += Correction;
        }while (Math.Abs(Correction) > 0.00001); //Corresponds to an error of 0.86 of a second

        return(JDE);
    }
Example #4
0
//Static methods

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

    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 = CT.M360(280.4664567 + 360007.6982779 * rho + 0.03032028 * rhosquared + rhocubed / 49931 - rho4 / 15300 - rho5 / 2000000);

        //Calculate the Suns apparent right ascension
        double SunLong    = CAASun.ApparentEclipticLongitude(JD);
        double SunLat     = CAASun.ApparentEclipticLatitude(JD);
        double epsilon    = CAANutation.TrueObliquityOfEcliptic(JD);
        COR    Equatorial = CT.Ec2Eq(SunLong, SunLat, epsilon);

        epsilon = CT.D2R(epsilon);
        double E = L0 - 0.0057183 - Equatorial.X * 15 + CT.DMS2D(0, 0, CAANutation.NutationInLongitude(JD)) * Math.Cos(epsilon);

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

        return(E);
    }
    public static double AutumnEquinox(int Year)
    {
        //calculate the approximate date
        double JDE = 0;

        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 = CAASun.ApparentEclipticLongitude(JDE);
            Correction = 58 * Math.Sin(CAACoordinateTransformation.DegreesToRadians(180 - SunLongitude));
            JDE       += Correction;
        }while (Math.Abs(Correction) > 0.00001); //Corresponds to an error of 0.86 of a second

        return(JDE);
    }
Example #6
0
    public static CAASelenographicMoonDetails CalculateSelenographicPositionOfSun(double JD)
    {
        double R       = CAAEarth.RadiusVector(JD) * 149597970;
        double Delta   = CAAMoon.RadiusVector(JD);
        double lambda0 = CAASun.ApparentEclipticLongitude(JD);
        double lambda  = CAAMoon.EclipticLongitude(JD);
        double beta    = CAAMoon.EclipticLatitude(JD);

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

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

        //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 = CAACoordinateTransformation.MapTo0To360Range(450 - details.l0);
        return(details);
    }
Example #7
0
    public static CAA2DCoordinate EclipticAberration(double Lambda, double Beta, double JD)
    {
        //What is the return value
        CAA2DCoordinate aberration = new CAA2DCoordinate();

        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;
        double k            = 20.49552;
        double SunLongitude = CAASun.GeometricEclipticLongitude(JD);

        //Convert to radians
        pi           = CAACoordinateTransformation.DegreesToRadians(pi);
        Lambda       = CAACoordinateTransformation.DegreesToRadians(Lambda);
        Beta         = CAACoordinateTransformation.DegreesToRadians(Beta);
        SunLongitude = CAACoordinateTransformation.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);
    }
Example #8
0
//Static methods
    public static CAANearParabolicObjectDetails Calculate(double JD, CAANearParabolicObjectElements elements)
    {
        double Epsilon = CAANutation.MeanObliquityOfEcliptic(elements.JDEquinox);

        double JD0 = JD;

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

        Epsilon = CAACoordinateTransformation.DegreesToRadians(Epsilon);
        double omega = CAACoordinateTransformation.DegreesToRadians(elements.omega);
        double w     = CAACoordinateTransformation.DegreesToRadians(elements.w);
        double i     = CAACoordinateTransformation.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);

        CAA3DCoordinate SunCoord = CAASun.EquatorialRectangularCoordinatesAnyEquinox(JD, elements.JDEquinox);

        for (int j = 0; j < 2; j++)
        {
            double v = 0;
            double r = 0;
            CalulateTrueAnnomalyAndRadius(JD0, 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    = omega + 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 = Math.Atan2(y, x);
                details.HeliocentricEclipticLongitude = CAACoordinateTransformation.MapTo0To24Range(CAACoordinateTransformation.RadiansToDegrees(details.HeliocentricEclipticLongitude) / 15);
                details.HeliocentricEclipticLatitude  = Math.Asin(z / r);
                details.HeliocentricEclipticLatitude  = CAACoordinateTransformation.RadiansToDegrees(details.HeliocentricEclipticLatitude);
            }

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

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

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

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

                details.Elongation = CAACoordinateTransformation.RadiansToDegrees(Math.Acos((RES * RES + Distance * Distance - r * r) / (2 * RES * Distance)));
                details.PhaseAngle = CAACoordinateTransformation.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);
    }
    public static EOD CalculateElements(double JD, EOE elements)
    {
        double Epsilon = CAANutation.MeanObliquityOfEcliptic(elements.JDEquinox);

        double JD0 = JD;

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

        Epsilon = CT.D2R(Epsilon);
        double omega = CT.D2R(elements.omega);
        double w     = CT.D2R(elements.w);
        double i     = CT.D2R(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);
        double n = ELL.MeanMotionFromSemiMajorAxis(elements.a);

        C3D SunCoord = CAASun.EquatorialRectangularCoordinatesAnyEquinox(JD, elements.JDEquinox);

        for (int j = 0; j < 2; j++)
        {
            double M = n * (JD0 - elements.T);
            double E = CAAKepler.Calculate(M, elements.e);
            E = CT.D2R(E);
            double v = 2 * Math.Atan(Math.Sqrt((1 + elements.e) / (1 - elements.e)) * Math.Tan(E / 2));
            double r = elements.a * (1 - elements.e * Math.Cos(E));
            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    = omega + 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 = Math.Atan2(y, x);
                details.HeliocentricEclipticLongitude = CT.M24(CT.R2D(details.HeliocentricEclipticLongitude) / 15);
                details.HeliocentricEclipticLatitude  = Math.Asin(z / r);
                details.HeliocentricEclipticLatitude  = CT.R2D(details.HeliocentricEclipticLatitude);
            }

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

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

            if (j == 0)
            {
                details.TrueGeocentricRA          = CT.M24(Alpha / 15);
                details.TrueGeocentricDeclination = Delta;
                details.TrueGeocentricDistance    = Distance;
                details.TrueGeocentricLightTime   = DistanceToLightTime(Distance);
            }
            else
            {
                details.AstrometricGeocenticRA           = CT.M24(Alpha / 15);
                details.AstrometricGeocentricDeclination = Delta;
                details.AstrometricGeocentricDistance    = Distance;
                details.AstrometricGeocentricLightTime   = DistanceToLightTime(Distance);

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

                details.Elongation = Math.Acos((RES * RES + Distance * Distance - r * r) / (2 * RES * Distance));
                details.Elongation = CT.R2D(details.Elongation);

                details.PhaseAngle = Math.Acos((r * r + Distance * Distance - RES * RES) / (2 * r * Distance));
                details.PhaseAngle = CT.R2D(details.PhaseAngle);
            }

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

        return(details);
    }
Example #10
0
    public static EPD Calculate(double JD, EO @object)
    {
        //What will the the return value
        EPD details = new EPD();

        double JD0   = JD;
        double L0    = 0;
        double B0    = 0;
        double R0    = 0;
        double cosB0 = 0;

        if (@object != EO.SUN)
        {
            L0    = CAAEarth.EclipticLongitude(JD0);
            B0    = CAAEarth.EclipticLatitude(JD0);
            R0    = CAAEarth.RadiusVector(JD0);
            L0    = CT.D2R(L0);
            B0    = CT.D2R(B0);
            cosB0 = Math.Cos(B0);
        }


        //Calculate the initial values
        double L = 0;
        double B = 0;
        double R = 0;

        double Lrad;
        double Brad;
        double cosB;
        double cosL;
        double x;
        double y;
        double z;
        bool   bRecalc      = true;
        bool   bFirstRecalc = true;
        double LPrevious    = 0;
        double BPrevious    = 0;
        double RPrevious    = 0;

        while (bRecalc)
        {
            switch (@object)
            {
            case EO.SUN:
            {
                L = CAASun.GeometricEclipticLongitude(JD0);
                B = CAASun.GeometricEclipticLatitude(JD0);
                R = CAAEarth.RadiusVector(JD0);
                break;
            }

            case EO.MERCURY:
            {
                L = CAAMercury.EclipticLongitude(JD0);
                B = CAAMercury.EclipticLatitude(JD0);
                R = CAAMercury.RadiusVector(JD0);
                break;
            }

            case EO.VENUS:
            {
                L = CAAVenus.EclipticLongitude(JD0);
                B = CAAVenus.EclipticLatitude(JD0);
                R = CAAVenus.RadiusVector(JD0);
                break;
            }

            case EO.MARS:
            {
                L = CAAMars.EclipticLongitude(JD0);
                B = CAAMars.EclipticLatitude(JD0);
                R = CAAMars.RadiusVector(JD0);
                break;
            }

            case EO.JUPITER:
            {
                L = CAAJupiter.EclipticLongitude(JD0);
                B = CAAJupiter.EclipticLatitude(JD0);
                R = CAAJupiter.RadiusVector(JD0);
                break;
            }

            case EO.SATURN:
            {
                L = CAASaturn.EclipticLongitude(JD0);
                B = CAASaturn.EclipticLatitude(JD0);
                R = CAASaturn.RadiusVector(JD0);
                break;
            }

            case EO.URANUS:
            {
                L = CAAUranus.EclipticLongitude(JD0);
                B = CAAUranus.EclipticLatitude(JD0);
                R = CAAUranus.RadiusVector(JD0);
                break;
            }

            case EO.NEPTUNE:
            {
                L = CAANeptune.EclipticLongitude(JD0);
                B = CAANeptune.EclipticLatitude(JD0);
                R = CAANeptune.RadiusVector(JD0);
                break;
            }

            case EO.PLUTO:
            {
                L = CAAPluto.EclipticLongitude(JD0);
                B = CAAPluto.EclipticLatitude(JD0);
                R = CAAPluto.RadiusVector(JD0);
                break;
            }

            default:
            {
                Debug.Assert(false);
                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 distance = 0;
                if (@object != EO.SUN)
                {
                    Lrad     = CT.D2R(L);
                    Brad     = CT.D2R(B);
                    cosB     = Math.Cos(Brad);
                    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);
                    distance = Math.Sqrt(x * x + y * y + z * z);
                }
                else
                {
                    distance = R; //Distance to the sun from the earth is in fact the radius vector
                }
                //Prepare for the next loop around
                JD0 = JD - ELL.DistanceToLightTime(distance);
            }
        }

        Lrad = CT.D2R(L);
        Brad = CT.D2R(B);
        cosB = Math.Cos(Brad);
        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);
        double x2 = x * x;
        double y2 = y * y;

        details.ApparentGeocentricLatitude  = CT.R2D(Math.Atan2(z, Math.Sqrt(x2 + y2)));
        details.ApparentGeocentricDistance  = Math.Sqrt(x2 + y2 + z * z);
        details.ApparentGeocentricLongitude = CT.M360(CT.R2D(Math.Atan2(y, x)));
        details.ApparentLightTime           = ELL.DistanceToLightTime(details.ApparentGeocentricDistance);

        //Adjust for Aberration
        COR Aberration = ABR.EclipticAberration(details.ApparentGeocentricLongitude, details.ApparentGeocentricLatitude, JD);

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

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

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

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

        details.ApparentGeocentricLongitude += CT.DMS2D(0, 0, NutationInLongitude);

        //Convert to RA and Dec
        COR ApparentEqu = CT.Ec2Eq(details.ApparentGeocentricLongitude, details.ApparentGeocentricLatitude, Epsilon);

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

        return(details);
    }
Example #11
0
//Static methods
    public static CAAGalileanMoonsDetails Calculate(double JD)
    {
        //Calculate the position of the Sun
        double sunlong    = CAASun.GeometricEclipticLongitude(JD);
        double sunlongrad = CAACoordinateTransformation.DegreesToRadians(sunlong);
        double beta       = CAASun.GeometricEclipticLatitude(JD);
        double betarad    = CAACoordinateTransformation.DegreesToRadians(beta);
        double R          = CAAEarth.RadiusVector(JD);

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

        double l    = 0;
        double lrad = 0;
        double b    = 0;
        double brad = 0;
        double r    = 0;

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

            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 = CAAElliptical.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
        CAAGalileanMoonsDetails details1 = CalculateHelper(JD, sunlongrad, betarad, R);

        FillInPhenomenaDetails(ref details1.Satellite1);
        FillInPhenomenaDetails(ref details1.Satellite2);
        FillInPhenomenaDetails(ref details1.Satellite3);
        FillInPhenomenaDetails(ref details1.Satellite4);

        //Calculate the the light travel time from Jupiter to the Sun
        JD1   = JD - EarthLightTravelTime;
        l     = CAAJupiter.EclipticLongitude(JD1);
        lrad  = CAACoordinateTransformation.DegreesToRadians(l);
        b     = CAAJupiter.EclipticLatitude(JD1);
        brad  = CAACoordinateTransformation.DegreesToRadians(b);
        r     = CAAJupiter.RadiusVector(JD1);
        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 = CAAElliptical.DistanceToLightTime(DELTA);

        //Calculate the details as seen from the Sun
        CAAGalileanMoonsDetails details2 = CalculateHelper(JD + SunLightTravelTime - EarthLightTravelTime, sunlongrad, betarad, 0);

        FillInPhenomenaDetails(ref details2.Satellite1);
        FillInPhenomenaDetails(ref details2.Satellite2);
        FillInPhenomenaDetails(ref details2.Satellite3);
        FillInPhenomenaDetails(ref details2.Satellite4);

        //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;
//C++ TO C# CONVERTER WARNING: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created if it does not yet exist:
//ORIGINAL LINE: details1.Satellite1.ApparentShadowRectangularCoordinates = details2.Satellite1.ApparentRectangularCoordinates;
        details1.Satellite1.ApparentShadowRectangularCoordinates = details2.Satellite1.ApparentRectangularCoordinates;
//C++ TO C# CONVERTER WARNING: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created if it does not yet exist:
//ORIGINAL LINE: details1.Satellite2.ApparentShadowRectangularCoordinates = details2.Satellite2.ApparentRectangularCoordinates;
        details1.Satellite2.ApparentShadowRectangularCoordinates = details2.Satellite2.ApparentRectangularCoordinates;
//C++ TO C# CONVERTER WARNING: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created if it does not yet exist:
//ORIGINAL LINE: details1.Satellite3.ApparentShadowRectangularCoordinates = details2.Satellite3.ApparentRectangularCoordinates;
        details1.Satellite3.ApparentShadowRectangularCoordinates = details2.Satellite3.ApparentRectangularCoordinates;
//C++ TO C# CONVERTER WARNING: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created if it does not yet exist:
//ORIGINAL LINE: details1.Satellite4.ApparentShadowRectangularCoordinates = details2.Satellite4.ApparentRectangularCoordinates;
        details1.Satellite4.ApparentShadowRectangularCoordinates = details2.Satellite4.ApparentRectangularCoordinates;
        return(details1);
    }
Example #12
0
//Static methods

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

    public static CAAPhysicalMarsDetails Calculate(double JD)
    {
        //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 = CT.D2R(Lambda0);
        double Beta0      = 63.2818 - 0.00394 * T;
        double Beta0rad   = CT.D2R(Beta0);

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

        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 brad     = 0;
        double r        = 0;

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

            //Step 3
            l    = CAAMars.EclipticLongitude(JD2);
            lrad = CT.D2R(l);
            b    = CAAMars.EclipticLatitude(JD2);
            brad = CT.D2R(b);
            r    = CAAMars.RadiusVector(JD2);

            //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 = ELL.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    = CT.R2D(lambdarad);
        double betarad   = Math.Atan2(z, Math.Sqrt(x * x + y * y));
        double beta      = CT.R2D(betarad);

        //Step 6
        details.DE = CT.R2D(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 = CT.D2R(N);

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

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

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

        //Step 10
        double e0             = CAANutation.MeanObliquityOfEcliptic(JD);
        double e0rad          = CT.D2R(e0);
        COR    PoleEquatorial = CT.Ec2Eq(Lambda0, Beta0, e0);
        double alpha0rad      = CT.H2R(PoleEquatorial.X);
        double delta0rad      = CT.D2R(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    = CT.R2H(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.w = CT.M360(W - CT.R2D(xi));

        //Step 13
        double NutationInLongitude = CAANutation.NutationInLongitude(JD);
        double NutationInObliquity = CAANutation.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;
        Lambda0rad = CT.D2R(Lambda0);
        lambda    += NutationInLongitude / 3600;
        lambdarad  = CT.D2R(lambda);
        e0        += NutationInObliquity / 3600;
        e0rad      = CT.D2R(e0rad);

        //Step 16
        COR    ApparentPoleEquatorial = CT.Ec2Eq(Lambda0, Beta0, e0);
        double alpha0dash             = CT.H2R(ApparentPoleEquatorial.X);
        double delta0dash             = CT.D2R(ApparentPoleEquatorial.Y);
        COR    ApparentMars           = CT.Ec2Eq(lambda, beta, e0);
        double alphadash = CT.H2R(ApparentMars.X);
        double deltadash = CT.D2R(ApparentMars.Y);

        //Step 17
        details.P = CT.M360(CT.R2D(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     = CAASun.GeometricEclipticLongitude(JD);
        double SunBeta       = CAASun.GeometricEclipticLatitude(JD);
        COR    SunEquatorial = CT.Ec2Eq(SunLambda, SunBeta, e0);

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

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

        return(details);
    }
Example #13
0
//Static methods
    public static CAASaturnMoonsDetails Calculate(double JD)
    {
        //Calculate the position of the Sun
        double sunlong    = CAASun.GeometricEclipticLongitude(JD);
        double sunlongrad = CAACoordinateTransformation.DegreesToRadians(sunlong);
        double beta       = CAASun.GeometricEclipticLatitude(JD);
        double betarad    = CAACoordinateTransformation.DegreesToRadians(beta);
        double R          = CAAEarth.RadiusVector(JD);

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

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

            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 = CAAElliptical.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
        CAASaturnMoonsDetails details1 = CalculateHelper(JD, sunlongrad, betarad, R);

        FillInPhenomenaDetails(ref details1.Satellite1);
        FillInPhenomenaDetails(ref details1.Satellite2);
        FillInPhenomenaDetails(ref details1.Satellite3);
        FillInPhenomenaDetails(ref details1.Satellite4);
        FillInPhenomenaDetails(ref details1.Satellite5);
        FillInPhenomenaDetails(ref details1.Satellite6);
        FillInPhenomenaDetails(ref details1.Satellite7);
        FillInPhenomenaDetails(ref details1.Satellite8);

        //Calculate the the light travel time from Saturn to the Sun
        JD1   = JD - EarthLightTravelTime;
        l     = CAASaturn.EclipticLongitude(JD1);
        lrad  = CAACoordinateTransformation.DegreesToRadians(l);
        b     = CAASaturn.EclipticLatitude(JD1);
        brad  = CAACoordinateTransformation.DegreesToRadians(b);
        r     = CAASaturn.RadiusVector(JD1);
        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 = CAAElliptical.DistanceToLightTime(DELTA);

        //Calculate the details as seen from the Sun
        CAASaturnMoonsDetails details2 = CalculateHelper(JD + SunLightTravelTime - EarthLightTravelTime, sunlongrad, betarad, 0);

        FillInPhenomenaDetails(ref details2.Satellite1);
        FillInPhenomenaDetails(ref details2.Satellite2);
        FillInPhenomenaDetails(ref details2.Satellite3);
        FillInPhenomenaDetails(ref details2.Satellite4);
        FillInPhenomenaDetails(ref details2.Satellite5);
        FillInPhenomenaDetails(ref details2.Satellite6);
        FillInPhenomenaDetails(ref details2.Satellite7);
        FillInPhenomenaDetails(ref details2.Satellite8);

        //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.Satellite5.bInEclipse       = details2.Satellite5.bInOccultation;
        details1.Satellite6.bInEclipse       = details2.Satellite6.bInOccultation;
        details1.Satellite7.bInEclipse       = details2.Satellite7.bInOccultation;
        details1.Satellite8.bInEclipse       = details2.Satellite8.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;
        details1.Satellite5.bInShadowTransit = details2.Satellite5.bInTransit;
        details1.Satellite6.bInShadowTransit = details2.Satellite6.bInTransit;
        details1.Satellite7.bInShadowTransit = details2.Satellite7.bInTransit;
        details1.Satellite8.bInShadowTransit = details2.Satellite8.bInTransit;

        return(details1);
    }