Beispiel #1
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);
    }
//Static methods

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

    public static CAAEclipticalElementDetails Calculate(double i0, double w0, double omega0, double JD0, double JD)
    {
        double T        = (JD0 - 2451545.0) / 36525;
        double Tsquared = T * T;
        double t        = (JD - JD0) / 36525;
        double tsquared = t * t;
        double tcubed   = tsquared * t;

        //Now convert to radians
        double i0rad     = CT.D2R(i0);
        double omega0rad = CT.D2R(omega0);

        double eta = (47.0029 - 0.06603 * T + 0.000598 * Tsquared) * t + (-0.03302 + 0.000598 * T) * tsquared + 0.00006 * tcubed;

        eta = CT.D2R(CT.DMS2D(0, 0, eta));

        double pi = 174.876384 * 3600 + 3289.4789 * T + 0.60622 * Tsquared - (869.8089 + 0.50491 * T) * t + 0.03536 * tsquared;

        pi = CT.D2R(CT.DMS2D(0, 0, pi));

        double p = (5029.0966 + 2.22226 * T - 0.000042 * Tsquared) * t + (1.11113 - 0.000042 * T) * tsquared - 0.000006 * tcubed;

        p = CT.D2R(CT.DMS2D(0, 0, p));

        double sini0rad        = Math.Sin(i0rad);
        double cosi0rad        = Math.Cos(i0rad);
        double sinomega0rad_pi = Math.Sin(omega0rad - pi);
        double cosomega0rad_pi = Math.Cos(omega0rad - pi);
        double sineta          = Math.Sin(eta);
        double coseta          = Math.Cos(eta);
        double A    = sini0rad * sinomega0rad_pi;
        double B    = -sineta * cosi0rad + coseta * sini0rad * cosomega0rad_pi;
        double irad = Math.Asin(Math.Sqrt(A * A + B * B));

        CAAEclipticalElementDetails details = new CAAEclipticalElementDetails();

        details.i = CT.R2D(irad);
        double cosi = cosi0rad * coseta + sini0rad * sineta * cosomega0rad_pi;

        if (cosi < 0)
        {
            details.i = 180 - details.i;
        }

        double phi = pi + p;

        details.omega = CT.M360(CT.R2D(Math.Atan2(A, B) + phi));

        A = -sineta * sinomega0rad_pi;
        B = sini0rad * coseta - cosi0rad * sineta * cosomega0rad_pi;
        double deltaw = CT.R2D(Math.Atan2(A, B));

        details.w = CT.M360(w0 + deltaw);

        return(details);
    }
Beispiel #3
0
    public static double CorrectionInLatitude(double Longitude, double JD)
    {
        double T     = (JD - 2451545) / 36525;
        double Ldash = Longitude - 1.397 * T - 0.00031 * T * T;

        //Convert to radians
        Ldash     = CT.D2R(Ldash);
        Longitude = CT.D2R(Longitude);

        double @value = 0.03916 * (Math.Cos(Ldash) - Math.Sin(Ldash));

        return(CT.DMS2D(0, 0, @value));
    }
    public static double ApparentEclipticLongitude(double JD)
    {
        double Longitude = GeometricFK5EclipticLongitude(JD);

        //Apply the correction in longitude due to nutation
        Longitude += CT.DMS2D(0, 0, CAANutation.NutationInLongitude(JD));

        //Apply the correction in longitude due to aberration
        double R = CAAEarth.RadiusVector(JD);

        Longitude -= CT.DMS2D(0, 0, 20.4898 / R);

        return(Longitude);
    }
Beispiel #5
0
    public static double MeanObliquityOfEcliptic(double JD)
    {
        double U        = (JD - 2451545) / 3652500;
        double Usquared = U * U;
        double Ucubed   = Usquared * U;
        double U4       = Ucubed * U;
        double U5       = U4 * U;
        double U6       = U5 * U;
        double U7       = U6 * U;
        double U8       = U7 * U;
        double U9       = U8 * U;
        double U10      = U9 * U;


        return(CT.DMS2D(23, 26, 21.448) - CT.DMS2D(0, 0, 4680.93) * U - CT.DMS2D(0, 0, 1.55) * Usquared + CT.DMS2D(0, 0, 1999.25) * Ucubed - CT.DMS2D(0, 0, 51.38) * U4 - CT.DMS2D(0, 0, 249.67) * U5 - CT.DMS2D(0, 0, 39.05) * U6 + CT.DMS2D(0, 0, 7.12) * U7 + CT.DMS2D(0, 0, 27.87) * U8 + CT.DMS2D(0, 0, 5.79) * U9 + CT.DMS2D(0, 0, 2.45) * U10);
    }
Beispiel #6
0
    public static C3D ConvertVSOPToFK5AnyEquinox(C3D @value, double JDEquinox)
    {
        double t        = (JDEquinox - 2451545.0) / 36525;
        double tsquared = t * t;
        double tcubed   = tsquared * t;

        double sigma = 2306.2181 * t + 0.30188 * tsquared + 0.017988 * tcubed;

        sigma = CT.D2R(CT.DMS2D(0, 0, sigma));

        double zeta = 2306.2181 * t + 1.09468 * tsquared + 0.018203 * tcubed;

        zeta = CT.D2R(CT.DMS2D(0, 0, zeta));

        double phi = 2004.3109 * t - 0.42665 * tsquared - 0.041833 * tcubed;

        phi = CT.D2R(CT.DMS2D(0, 0, phi));

        double cossigma = Math.Cos(sigma);
        double coszeta  = Math.Cos(zeta);
        double cosphi   = Math.Cos(phi);
        double sinsigma = Math.Sin(sigma);
        double sinzeta  = Math.Sin(zeta);
        double sinphi   = Math.Sin(phi);

        double xx = cossigma * coszeta * cosphi - sinsigma * sinzeta;
        double xy = sinsigma * coszeta + cossigma * sinzeta * cosphi;
        double xz = cossigma * sinphi;
        double yx = -cossigma * sinzeta - sinsigma * coszeta * cosphi;
        double yy = cossigma * coszeta - sinsigma * sinzeta * cosphi;
        double yz = -sinsigma * sinphi;
        double zx = -coszeta * sinphi;
        double zy = -sinzeta * sinphi;
        double zz = cosphi;

        C3D result = new C3D();

        result.X = xx * @value.X + yx * @value.Y + zx * @value.Z;
        result.Y = xy * @value.X + yy * @value.Y + zy * @value.Z;
        result.Z = xz * @value.X + yz * @value.Y + zz * @value.Z;

        return(result);
    }
    public static COR PrecessEquatorialFK4(double Alpha, double Delta, double JD0, double JD)
    {
        double T        = (JD0 - 2415020.3135) / 36524.2199;
        double t        = (JD - JD0) / 36524.2199;
        double tsquared = t * t;
        double tcubed   = tsquared * t;

        //Now convert to radians
        Alpha = CT.H2R(Alpha);
        Delta = CT.D2R(Delta);

        double sigma = (2304.250 + 1.396 * T) * t + 0.302 * tsquared + 0.018 * tcubed;

        sigma = CT.D2R(CT.DMS2D(0, 0, sigma));

        double zeta = 0.791 * tsquared + 0.001 * tcubed;

        zeta  = CT.D2R(CT.DMS2D(0, 0, zeta));
        zeta += sigma;

        double phi = (2004.682 - 0.853 * T) * t - 0.426 * tsquared - 0.042 * tcubed;

        phi = CT.D2R(CT.DMS2D(0, 0, phi));

        double A = Math.Cos(Delta) * Math.Sin(Alpha + sigma);
        double B = Math.Cos(phi) * Math.Cos(Delta) * Math.Cos(Alpha + sigma) - Math.Sin(phi) * Math.Sin(Delta);
        double C = Math.Sin(phi) * Math.Cos(Delta) * Math.Cos(Alpha + sigma) + Math.Cos(phi) * Math.Sin(Delta);

        COR @value = new COR();

        @value.X = CT.R2H(Math.Atan2(A, B) + zeta);
        if (@value.X < 0)
        {
            @value.X += 24;
        }
        @value.Y = CT.R2D(Math.Asin(C));

        return(@value);
    }
//Static methods
    public static COR PrecessEquatorial(double Alpha, double Delta, double JD0, double JD)
    {
        double T        = (JD0 - 2451545.0) / 36525;
        double Tsquared = T * T;
        double t        = (JD - JD0) / 36525;
        double tsquared = t * t;
        double tcubed   = tsquared * t;

        //Now convert to radians
        Alpha = CT.H2R(Alpha);
        Delta = CT.D2R(Delta);

        double sigma = (2306.2181 + 1.39656 * T - 0.000139 * Tsquared) * t + (0.30188 - 0.0000344 * T) * tsquared + 0.017988 * tcubed;

        sigma = CT.D2R(CT.DMS2D(0, 0, sigma));

        double zeta = (2306.2181 + 1.39656 * T - 0.000138 * Tsquared) * t + (1.09468 + 0.000066 * T) * tsquared + 0.018203 * tcubed;

        zeta = CT.D2R(CT.DMS2D(0, 0, zeta));

        double phi = (2004.3109 - 0.8533 * T - 0.000217 * Tsquared) * t - (0.42665 + 0.000217 * T) * tsquared - 0.041833 * tcubed;

        phi = CT.D2R(CT.DMS2D(0, 0, phi));

        double A = Math.Cos(Delta) * Math.Sin(Alpha + sigma);
        double B = Math.Cos(phi) * Math.Cos(Delta) * Math.Cos(Alpha + sigma) - Math.Sin(phi) * Math.Sin(Delta);
        double C = Math.Sin(phi) * Math.Cos(Delta) * Math.Cos(Alpha + sigma) + Math.Cos(phi) * Math.Sin(Delta);

        COR @value = new COR();

        @value.X = CT.R2H(Math.Atan2(A, B) + zeta);
        if (@value.X < 0)
        {
            @value.X += 24;
        }
        @value.Y = CT.R2D(Math.Asin(C));

        return(@value);
    }
    public static COR PrecessEcliptic(double Lambda, double Beta, double JD0, double JD)
    {
        double T        = (JD0 - 2451545.0) / 36525;
        double Tsquared = T * T;
        double t        = (JD - JD0) / 36525;
        double tsquared = t * t;
        double tcubed   = tsquared * t;

        //Now convert to radians
        Lambda = CT.D2R(Lambda);
        Beta   = CT.D2R(Beta);

        double eta = (47.0029 - 0.06603 * T + 0.000598 * Tsquared) * t + (-0.03302 + 0.000598 * T) * tsquared + 0.00006 * tcubed;

        eta = CT.D2R(CT.DMS2D(0, 0, eta));

        double pi = 174.876384 * 3600 + 3289.4789 * T + 0.60622 * Tsquared - (869.8089 + 0.50491 * T) * t + 0.03536 * tsquared;

        pi = CT.D2R(CT.DMS2D(0, 0, pi));

        double p = (5029.0966 + 2.22226 * T - 0.000042 * Tsquared) * t + (1.11113 - 0.000042 * T) * tsquared - 0.000006 * tcubed;

        p = CT.D2R(CT.DMS2D(0, 0, p));

        double A = Math.Cos(eta) * Math.Cos(Beta) * Math.Sin(pi - Lambda) - Math.Sin(eta) * Math.Sin(Beta);
        double B = Math.Cos(Beta) * Math.Cos(pi - Lambda);
        double C = Math.Cos(eta) * Math.Sin(Beta) + Math.Sin(eta) * Math.Cos(Beta) * Math.Sin(pi - Lambda);

        COR @value = new COR();

        @value.X = CT.R2D(p + pi - Math.Atan2(A, B));
        if (@value.X < 0)
        {
            @value.X += 360;
        }
        @value.Y = CT.R2D(Math.Asin(C));

        return(@value);
    }
//Static methods

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

    public static CAAPhysicalSunDetails Calculate(double JD)
    {
        double theta = CT.M360((JD - 2398220) * 360 / 25.38);
        double I     = 7.25;
        double K     = 73.6667 + 1.3958333 * (JD - 2396758) / 36525;

        //Calculate the apparent longitude of the sun (excluding the effect of nutation)
        double L           = CAAEarth.EclipticLongitude(JD);
        double R           = CAAEarth.RadiusVector(JD);
        double SunLong     = L + 180 - CT.DMS2D(0, 0, 20.4898 / R);
        double SunLongDash = SunLong + CT.DMS2D(0, 0, CAANutation.NutationInLongitude(JD));

        double epsilon = CAANutation.TrueObliquityOfEcliptic(JD);

        //Convert to radians
        epsilon     = CT.D2R(epsilon);
        SunLong     = CT.D2R(SunLong);
        SunLongDash = CT.D2R(SunLongDash);
        K           = CT.D2R(K);
        I           = CT.D2R(I);
        theta       = CT.D2R(theta);

        double x = Math.Atan(-Math.Cos(SunLong) * Math.Tan(epsilon));
        double y = Math.Atan(-Math.Cos(SunLong - K) * Math.Tan(I));

        CAAPhysicalSunDetails details = new CAAPhysicalSunDetails();

        details.P  = CT.R2D(x + y);
        details.B0 = CT.R2D(Math.Asin(Math.Sin(SunLong - K) * Math.Sin(I)));

        double eta = Math.Atan(Math.Tan(SunLong - K) * Math.Cos(I));

        details.L0 = CT.M360(CT.R2D(eta - theta));

        return(details);
    }
Beispiel #11
0
 public static double TrueObliquityOfEcliptic(double JD)
 {
     return(MeanObliquityOfEcliptic(JD) + CT.DMS2D(0, 0, NutationInObliquity(JD)));
 }
    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);
    }