Beispiel #1
0
    public static CAAEclipticalElementDetails FK4B1950ToFK5J2000(double i0, double w0, double omega0)
    {
        //convert to radians
        double L         = CAACoordinateTransformation.DegreesToRadians(5.19856209);
        double J         = CAACoordinateTransformation.DegreesToRadians(0.00651966);
        double i0rad     = CAACoordinateTransformation.DegreesToRadians(i0);
        double omega0rad = CAACoordinateTransformation.DegreesToRadians(omega0);
        double sini0rad  = Math.Sin(i0rad);
        double cosi0rad  = Math.Cos(i0rad);

        //Calculate some values used later
        double cosJ = Math.Cos(J);
        double sinJ = Math.Sin(J);
        double W    = L + omega0rad;
        double cosW = Math.Cos(W);
        double sinW = Math.Sin(W);
        double A    = sinJ * sinW;
        double B    = sini0rad * cosJ + cosi0rad * sinJ * cosW;

        //Calculate the values
        CAAEclipticalElementDetails details = new CAAEclipticalElementDetails();

        details.i = CAACoordinateTransformation.RadiansToDegrees(Math.Asin(Math.Sqrt(A * A + B * B)));
        double cosi = cosi0rad * cosJ - sini0rad * sinJ * cosW;

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

        details.w     = CAACoordinateTransformation.MapTo0To360Range(w0 + CAACoordinateTransformation.RadiansToDegrees(Math.Atan2(A, B)));
        details.omega = CAACoordinateTransformation.MapTo0To360Range(CAACoordinateTransformation.RadiansToDegrees(Math.Atan2(sini0rad * sinW, cosi0rad * sinJ + sini0rad * cosJ * cosW)) - 4.50001688);

        return(details);
    }
Beispiel #2
0
    //////////////////////////////// Implementation ///////////////////////////////

    protected static void HelperSubroutine(double e, double lambdadash, double p, double a, double omega, double i, double c1, double s1, ref double r, ref double lambda, ref double gamma, ref double w)
    {
        double e2 = e * e;
        double e3 = e2 * e;
        double e4 = e3 * e;
        double e5 = e4 * e;
        double M  = CAACoordinateTransformation.DegreesToRadians(lambdadash - p);

        double Crad = (2 * e - 0.25 * e3 + 0.0520833333 * e5) * Math.Sin(M) + (1.25 * e2 - 0.458333333 * e4) * Math.Sin(2 * M) + (1.083333333 * e3 - 0.671875 * e5) * Math.Sin(3 * M) + 1.072917 * e4 * Math.Sin(4 * M) + 1.142708 * e5 * Math.Sin(5 * M);
        double C    = CAACoordinateTransformation.RadiansToDegrees(Crad);

        r = a * (1 - e2) / (1 + e * Math.Cos(M + Crad));
        double g    = omega - 168.8112;
        double grad = CAACoordinateTransformation.DegreesToRadians(g);
        double irad = CAACoordinateTransformation.DegreesToRadians(i);
        double a1   = Math.Sin(irad) * Math.Sin(grad);
        double a2   = c1 * Math.Sin(irad) * Math.Cos(grad) - s1 * Math.Cos(irad);

        gamma = CAACoordinateTransformation.RadiansToDegrees(Math.Asin(Math.Sqrt(a1 * a1 + a2 * a2)));
        double urad = Math.Atan2(a1, a2);
        double u    = CAACoordinateTransformation.RadiansToDegrees(urad);

        w = CAACoordinateTransformation.MapTo0To360Range(168.8112 + u);
        double h      = c1 * Math.Sin(irad) - s1 * Math.Cos(irad) * Math.Cos(grad);
        double psirad = Math.Atan2(s1 * Math.Sin(grad), h);
        double psi    = CAACoordinateTransformation.RadiansToDegrees(psirad);

        lambda = lambdadash + C + u - g - psi;
    }
Beispiel #3
0
    public static CAA2DCoordinate Equatorial2Topocentric(double Alpha, double Delta, double Distance, double Longitude, double Latitude, double Height, double JD)
    {
        double RhoSinThetaPrime = CAAGlobe.RhoSinThetaPrime(Latitude, Height);
        double RhoCosThetaPrime = CAAGlobe.RhoCosThetaPrime(Latitude, Height);

        //Calculate the Sidereal time
        double theta = CAASidereal.ApparentGreenwichSiderealTime(JD);

        //Convert to radians
        Delta = CAACoordinateTransformation.DegreesToRadians(Delta);
        double cosDelta = Math.Cos(Delta);

        //Calculate the Parallax
        double pi    = Math.Asin(GlobalMembersStdafx.g_AAParallax_C1 / Distance);
        double sinpi = Math.Sin(pi);

        //Calculate the hour angle
        double H    = CAACoordinateTransformation.HoursToRadians(theta - Longitude / 15 - Alpha);
        double cosH = Math.Cos(H);
        double sinH = Math.Sin(H);

        //Calculate the adjustment in right ascension
        double DeltaAlpha = Math.Atan2(-RhoCosThetaPrime * sinpi * sinH, cosDelta - RhoCosThetaPrime * sinpi * cosH);

        CAA2DCoordinate Topocentric = new CAA2DCoordinate();

        Topocentric.X = CAACoordinateTransformation.MapTo0To24Range(Alpha + CAACoordinateTransformation.RadiansToHours(DeltaAlpha));
        Topocentric.Y = CAACoordinateTransformation.RadiansToDegrees(Math.Atan2((Math.Sin(Delta) - RhoSinThetaPrime * sinpi) * Math.Cos(DeltaAlpha), cosDelta - RhoCosThetaPrime * sinpi * cosH));

        return(Topocentric);
    }
Beispiel #4
0
//Conversion functions
    public static CAA2DCoordinate Equatorial2TopocentricDelta(double Alpha, double Delta, double Distance, double Longitude, double Latitude, double Height, double JD)
    {
        double RhoSinThetaPrime = CAAGlobe.RhoSinThetaPrime(Latitude, Height);
        double RhoCosThetaPrime = CAAGlobe.RhoCosThetaPrime(Latitude, Height);

        //Calculate the Sidereal time
        double theta = CAASidereal.ApparentGreenwichSiderealTime(JD);

        //Convert to radians
        Delta = CAACoordinateTransformation.DegreesToRadians(Delta);
        double cosDelta = Math.Cos(Delta);

        //Calculate the Parallax
        double pi = Math.Asin(GlobalMembersStdafx.g_AAParallax_C1 / Distance);

        //Calculate the hour angle
        double H    = CAACoordinateTransformation.HoursToRadians(theta - Longitude / 15 - Alpha);
        double cosH = Math.Cos(H);
        double sinH = Math.Sin(H);

        CAA2DCoordinate DeltaTopocentric = new CAA2DCoordinate();

        DeltaTopocentric.X = CAACoordinateTransformation.RadiansToHours(-pi * RhoCosThetaPrime * sinH / cosDelta);
        DeltaTopocentric.Y = CAACoordinateTransformation.RadiansToDegrees(-pi * (RhoSinThetaPrime * cosDelta - RhoCosThetaPrime * cosH * Math.Sin(Delta)));
        return(DeltaTopocentric);
    }
//Static methods

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

    public static double EclipticLongitude(double JD)
    {
        double rho        = (JD - 2451545) / 365250;
        double rhosquared = rho * rho;
        double rhocubed   = rhosquared * rho;
        double rho4       = rhocubed * rho;

        //Calculate L0
        int    nL0Coefficients = GlobalMembersStdafx.g_L0NeptuneCoefficients.Length;
        double L0 = 0;
        int    i;

        for (i = 0; i < nL0Coefficients; i++)
        {
            L0 += GlobalMembersStdafx.g_L0NeptuneCoefficients[i].A * Math.Cos(GlobalMembersStdafx.g_L0NeptuneCoefficients[i].B + GlobalMembersStdafx.g_L0NeptuneCoefficients[i].C * rho);
        }

        //Calculate L1
        int    nL1Coefficients = GlobalMembersStdafx.g_L1NeptuneCoefficients.Length;
        double L1 = 0;

        for (i = 0; i < nL1Coefficients; i++)
        {
            L1 += GlobalMembersStdafx.g_L1NeptuneCoefficients[i].A * Math.Cos(GlobalMembersStdafx.g_L1NeptuneCoefficients[i].B + GlobalMembersStdafx.g_L1NeptuneCoefficients[i].C * rho);
        }

        //Calculate L2
        int    nL2Coefficients = GlobalMembersStdafx.g_L2NeptuneCoefficients.Length;
        double L2 = 0;

        for (i = 0; i < nL2Coefficients; i++)
        {
            L2 += GlobalMembersStdafx.g_L2NeptuneCoefficients[i].A * Math.Cos(GlobalMembersStdafx.g_L2NeptuneCoefficients[i].B + GlobalMembersStdafx.g_L2NeptuneCoefficients[i].C * rho);
        }

        //Calculate L3
        int    nL3Coefficients = GlobalMembersStdafx.g_L3NeptuneCoefficients.Length;
        double L3 = 0;

        for (i = 0; i < nL3Coefficients; i++)
        {
            L3 += GlobalMembersStdafx.g_L3NeptuneCoefficients[i].A * Math.Cos(GlobalMembersStdafx.g_L3NeptuneCoefficients[i].B + GlobalMembersStdafx.g_L3NeptuneCoefficients[i].C * rho);
        }

        //Calculate L4
        int    nL4Coefficients = GlobalMembersStdafx.g_L4NeptuneCoefficients.Length;
        double L4 = 0;

        for (i = 0; i < nL4Coefficients; i++)
        {
            L4 += GlobalMembersStdafx.g_L4NeptuneCoefficients[i].A * Math.Cos(GlobalMembersStdafx.g_L4NeptuneCoefficients[i].B + GlobalMembersStdafx.g_L4NeptuneCoefficients[i].C * rho);
        }


        double @value = (L0 + L1 * rho + L2 * rhosquared + L3 * rhocubed + L4 * rho4) / 100000000;

        //convert results back to degrees
        @value = CAACoordinateTransformation.MapTo0To360Range(CAACoordinateTransformation.RadiansToDegrees(@value));
        return(@value);
    }
//Static methods
//Tangible Process Only End


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

    public static CAABinaryStarDetails Calculate(double t, double P, double T, double e, double a, double i, double omega, double w)
    {
        double n = 360 / P;
        double M = CAACoordinateTransformation.MapTo0To360Range(n * (t - T));
        double E = CAAKepler.Calculate(M, e);

        E     = CAACoordinateTransformation.DegreesToRadians(E);
        i     = CAACoordinateTransformation.DegreesToRadians(i);
        w     = CAACoordinateTransformation.DegreesToRadians(w);
        omega = CAACoordinateTransformation.DegreesToRadians(omega);

        CAABinaryStarDetails details = new CAABinaryStarDetails();

        details.r = a * (1 - e * Math.Cos(E));

        double v = Math.Atan(Math.Sqrt((1 + e) / (1 - e)) * Math.Tan(E / 2)) * 2;

        details.Theta = Math.Atan2(Math.Sin(v + w) * Math.Cos(i), Math.Cos(v + w)) + omega;
        details.Theta = CAACoordinateTransformation.MapTo0To360Range(CAACoordinateTransformation.RadiansToDegrees(details.Theta));

        double sinvw = Math.Sin(v + w);
        double cosvw = Math.Cos(v + w);
        double cosi  = Math.Cos(i);

        details.Rho = details.r * Math.Sqrt((sinvw * sinvw * cosi * cosi) + (cosvw * cosvw));

        return(details);
    }
Beispiel #7
0
    public static double EclipticLatitude(double JD)
    {
        double rho        = (JD - 2451545) / 365250;
        double rhosquared = rho * rho;
        double rhocubed   = rhosquared * rho;
        double rho4       = rhocubed * rho;

        //Calculate B0
        int    nB0Coefficients = GlobalMembersStdafx.g_B0MarsCoefficients.Length;
        double B0 = 0;
        int    i;

        for (i = 0; i < nB0Coefficients; i++)
        {
            B0 += GlobalMembersStdafx.g_B0MarsCoefficients[i].A * Math.Cos(GlobalMembersStdafx.g_B0MarsCoefficients[i].B + GlobalMembersStdafx.g_B0MarsCoefficients[i].C * rho);
        }

        //Calculate B1
        int    nB1Coefficients = GlobalMembersStdafx.g_B1MarsCoefficients.Length;
        double B1 = 0;

        for (i = 0; i < nB1Coefficients; i++)
        {
            B1 += GlobalMembersStdafx.g_B1MarsCoefficients[i].A * Math.Cos(GlobalMembersStdafx.g_B1MarsCoefficients[i].B + GlobalMembersStdafx.g_B1MarsCoefficients[i].C * rho);
        }

        //Calculate B2
        int    nB2Coefficients = GlobalMembersStdafx.g_B2MarsCoefficients.Length;
        double B2 = 0;

        for (i = 0; i < nB2Coefficients; i++)
        {
            B2 += GlobalMembersStdafx.g_B2MarsCoefficients[i].A * Math.Cos(GlobalMembersStdafx.g_B2MarsCoefficients[i].B + GlobalMembersStdafx.g_B2MarsCoefficients[i].C * rho);
        }

        //Calculate B3
        int    nB3Coefficients = GlobalMembersStdafx.g_B3MarsCoefficients.Length;
        double B3 = 0;

        for (i = 0; i < nB3Coefficients; i++)
        {
            B3 += GlobalMembersStdafx.g_B3MarsCoefficients[i].A * Math.Cos(GlobalMembersStdafx.g_B3MarsCoefficients[i].B + GlobalMembersStdafx.g_B3MarsCoefficients[i].C * rho);
        }

        //Calculate B4
        int    nB4Coefficients = GlobalMembersStdafx.g_B4MarsCoefficients.Length;
        double B4 = 0;

        for (i = 0; i < nB4Coefficients; i++)
        {
            B4 += GlobalMembersStdafx.g_B4MarsCoefficients[i].A * Math.Cos(GlobalMembersStdafx.g_B4MarsCoefficients[i].B + GlobalMembersStdafx.g_B4MarsCoefficients[i].C * rho);
        }

        double @value = (B0 + B1 * rho + B2 * rhosquared + B3 * rhocubed + B4 * rho4) / 100000000;

        //convert results back to degrees
        @value = CAACoordinateTransformation.RadiansToDegrees(@value);
        return(@value);
    }
Beispiel #8
0
    public static double PhaseAngle(double GeocentricElongation, double EarthObjectDistance, double EarthSunDistance)
    {
        //Convert from degrees to radians
        GeocentricElongation = CAACoordinateTransformation.DegreesToRadians(GeocentricElongation);

        //Return the result
        return(CAACoordinateTransformation.MapTo0To360Range(CAACoordinateTransformation.RadiansToDegrees(Math.Atan2(EarthSunDistance * Math.Sin(GeocentricElongation), EarthObjectDistance - EarthSunDistance * Math.Cos(GeocentricElongation)))));
    }
Beispiel #9
0
//Static methods

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

    public static double ParallacticAngle(double HourAngle, double Latitude, double delta)
    {
        HourAngle = CAACoordinateTransformation.HoursToRadians(HourAngle);
        Latitude  = CAACoordinateTransformation.DegreesToRadians(Latitude);
        delta     = CAACoordinateTransformation.DegreesToRadians(delta);

        return(CAACoordinateTransformation.RadiansToDegrees(Math.Atan2(Math.Sin(HourAngle), Math.Tan(Latitude) * Math.Cos(delta) - Math.Sin(delta) * Math.Cos(HourAngle))));
    }
Beispiel #10
0
//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     = CAACoordinateTransformation.DegreesToRadians(i0);
        double omega0rad = CAACoordinateTransformation.DegreesToRadians(omega0);

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

        eta = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, eta));

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

        pi = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, pi));

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

        p = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(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 = CAACoordinateTransformation.RadiansToDegrees(irad);
        double cosi = cosi0rad * coseta + sini0rad * sineta * cosomega0rad_pi;

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

        double phi = pi + p;

        details.omega = CAACoordinateTransformation.MapTo0To360Range(CAACoordinateTransformation.RadiansToDegrees(Math.Atan2(A, B) + phi));

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

        details.w = CAACoordinateTransformation.MapTo0To360Range(w0 + deltaw);

        return(details);
    }
    public static double PhaseAngleRectangular(double x, double y, double z, double B, double L, double Delta)
    {
        //Convert from degrees to radians
        B = CAACoordinateTransformation.DegreesToRadians(B);
        L = CAACoordinateTransformation.DegreesToRadians(L);
        double cosB = Math.Cos(B);

        //Return the result
        return(CAACoordinateTransformation.MapTo0To360Range(CAACoordinateTransformation.RadiansToDegrees(Math.Acos((x * cosB * Math.Cos(L) + y * cosB * Math.Sin(L) + z * Math.Sin(B)) / Delta))));
    }
Beispiel #12
0
    public static double PositionAngle(double Alpha0, double Delta0, double Alpha, double Delta)
    {
        //Convert to radians
        Alpha0 = CAACoordinateTransformation.HoursToRadians(Alpha0);
        Alpha  = CAACoordinateTransformation.HoursToRadians(Alpha);
        Delta0 = CAACoordinateTransformation.DegreesToRadians(Delta0);
        Delta  = CAACoordinateTransformation.DegreesToRadians(Delta);

        return(CAACoordinateTransformation.MapTo0To360Range(CAACoordinateTransformation.RadiansToDegrees(Math.Atan2(Math.Cos(Delta0) * Math.Sin(Alpha0 - Alpha), Math.Sin(Delta0) * Math.Cos(Delta) - Math.Cos(Delta0) * Math.Sin(Delta) * Math.Cos(Alpha0 - Alpha)))));
    }
Beispiel #13
0
    public static double EclipticLongitudeOnHorizon(double LocalSiderealTime, double ObliquityOfEcliptic, double Latitude)
    {
        LocalSiderealTime   = CAACoordinateTransformation.HoursToRadians(LocalSiderealTime);
        Latitude            = CAACoordinateTransformation.DegreesToRadians(Latitude);
        ObliquityOfEcliptic = CAACoordinateTransformation.DegreesToRadians(ObliquityOfEcliptic);

        double @value = CAACoordinateTransformation.RadiansToDegrees(Math.Atan2(-Math.Cos(LocalSiderealTime), Math.Sin(ObliquityOfEcliptic) * Math.Tan(Latitude) + Math.Cos(ObliquityOfEcliptic) * Math.Sin(LocalSiderealTime)));

        return(CAACoordinateTransformation.MapTo0To360Range(@value));
    }
    public static double PhaseAngle(double R, double R0, double B, double L, double L0, double Delta)
    {
        //Convert from degrees to radians
        B  = CAACoordinateTransformation.DegreesToRadians(B);
        L  = CAACoordinateTransformation.DegreesToRadians(L);
        L0 = CAACoordinateTransformation.DegreesToRadians(L0);

        //Return the result
        return(CAACoordinateTransformation.MapTo0To360Range(CAACoordinateTransformation.RadiansToDegrees(Math.Acos((R - R0 * Math.Cos(B) * Math.Cos(L - L0)) / Delta))));
    }
Beispiel #15
0
    public static double AngleBetweenEclipticAndHorizon(double LocalSiderealTime, double ObliquityOfEcliptic, double Latitude)
    {
        LocalSiderealTime   = CAACoordinateTransformation.HoursToRadians(LocalSiderealTime);
        Latitude            = CAACoordinateTransformation.DegreesToRadians(Latitude);
        ObliquityOfEcliptic = CAACoordinateTransformation.DegreesToRadians(ObliquityOfEcliptic);

        double @value = CAACoordinateTransformation.RadiansToDegrees(Math.Acos(Math.Cos(ObliquityOfEcliptic) * Math.Sin(Latitude) - Math.Sin(ObliquityOfEcliptic) * Math.Cos(Latitude) * Math.Sin(LocalSiderealTime)));

        return(CAACoordinateTransformation.MapTo0To360Range(@value));
    }
Beispiel #16
0
    public static double AngleBetweenNorthCelestialPoleAndNorthPoleOfEcliptic(double Lambda, double Beta, double ObliquityOfEcliptic)
    {
        Lambda = CAACoordinateTransformation.DegreesToRadians(Lambda);
        Beta   = CAACoordinateTransformation.DegreesToRadians(Beta);
        ObliquityOfEcliptic = CAACoordinateTransformation.DegreesToRadians(ObliquityOfEcliptic);

        double @value = CAACoordinateTransformation.RadiansToDegrees(Math.Atan2(Math.Cos(Lambda) * Math.Tan(ObliquityOfEcliptic), Math.Sin(Beta) * Math.Sin(Lambda) * Math.Tan(ObliquityOfEcliptic) - Math.Cos(Beta)));

        return(CAACoordinateTransformation.MapTo0To360Range(@value));
    }
Beispiel #17
0
    //////////////////////////////// Implementation ///////////////////////////////

    protected static void CalculateOpticalLibration(double JD, double Lambda, double Beta, ref double ldash, ref double bdash, ref double ldash2, ref double bdash2, ref double epsilon, ref double omega, ref double DeltaU, ref double sigma, ref double I, ref double rho)
    {
        //Calculate the initial quantities
        double Lambdarad = CAACoordinateTransformation.DegreesToRadians(Lambda);
        double Betarad   = CAACoordinateTransformation.DegreesToRadians(Beta);

        I      = CAACoordinateTransformation.DegreesToRadians(1.54242);
        DeltaU = CAACoordinateTransformation.DegreesToRadians(CAANutation.NutationInLongitude(JD) / 3600);
        double F = CAACoordinateTransformation.DegreesToRadians(CAAMoon.ArgumentOfLatitude(JD));

        omega   = CAACoordinateTransformation.DegreesToRadians(CAAMoon.MeanLongitudeAscendingNode(JD));
        epsilon = CAANutation.MeanObliquityOfEcliptic(JD) + CAANutation.NutationInObliquity(JD) / 3600;

        //Calculate the optical librations
        double W = Lambdarad - DeltaU / 3600 - omega;
        double A = Math.Atan2(Math.Sin(W) * Math.Cos(Betarad) * Math.Cos(I) - Math.Sin(Betarad) * Math.Sin(I), Math.Cos(W) * Math.Cos(Betarad));

        ldash = CAACoordinateTransformation.MapTo0To360Range(CAACoordinateTransformation.RadiansToDegrees(A) - CAACoordinateTransformation.RadiansToDegrees(F));
        if (ldash > 180)
        {
            ldash -= 360;
        }
        bdash = Math.Asin(-Math.Sin(W) * Math.Cos(Betarad) * Math.Sin(I) - Math.Sin(Betarad) * Math.Cos(I));

        //Calculate the physical librations
        double T  = (JD - 2451545.0) / 36525;
        double K1 = 119.75 + 131.849 * T;

        K1 = CAACoordinateTransformation.DegreesToRadians(K1);
        double K2 = 72.56 + 20.186 * T;

        K2 = CAACoordinateTransformation.DegreesToRadians(K2);

        double M = CAAEarth.SunMeanAnomaly(JD);

        M = CAACoordinateTransformation.DegreesToRadians(M);
        double Mdash = CAAMoon.MeanAnomaly(JD);

        Mdash = CAACoordinateTransformation.DegreesToRadians(Mdash);
        double D = CAAMoon.MeanElongation(JD);

        D = CAACoordinateTransformation.DegreesToRadians(D);
        double E = CAAEarth.Eccentricity(JD);

        rho = -0.02752 * Math.Cos(Mdash) + -0.02245 * Math.Sin(F) + 0.00684 * Math.Cos(Mdash - 2 * F) + -0.00293 * Math.Cos(2 * F) + -0.00085 * Math.Cos(2 * F - 2 * D) + -0.00054 * Math.Cos(Mdash - 2 * D) + -0.00020 * Math.Sin(Mdash + F) + -0.00020 * Math.Cos(Mdash + 2 * F) + -0.00020 * Math.Cos(Mdash - F) + 0.00014 * Math.Cos(Mdash + 2 * F - 2 * D);

        sigma = -0.02816 * Math.Sin(Mdash) + 0.02244 * Math.Cos(F) + -0.00682 * Math.Sin(Mdash - 2 * F) + -0.00279 * Math.Sin(2 * F) + -0.00083 * Math.Sin(2 * F - 2 * D) + 0.00069 * Math.Sin(Mdash - 2 * D) + 0.00040 * Math.Cos(Mdash + F) + -0.00025 * Math.Sin(2 * Mdash) + -0.00023 * Math.Sin(Mdash + 2 * F) + 0.00020 * Math.Cos(Mdash - F) + 0.00019 * Math.Sin(Mdash - F) + 0.00013 * Math.Sin(Mdash + 2 * F - 2 * D) + -0.00010 * Math.Cos(Mdash - 3 * F);

        double tau = 0.02520 * E * Math.Sin(M) + 0.00473 * Math.Sin(2 * Mdash - 2 * F) + -0.00467 * Math.Sin(Mdash) + 0.00396 * Math.Sin(K1) + 0.00276 * Math.Sin(2 * Mdash - 2 * D) + 0.00196 * Math.Sin(omega) + -0.00183 * Math.Cos(Mdash - F) + 0.00115 * Math.Sin(Mdash - 2 * D) + -0.00096 * Math.Sin(Mdash - D) + 0.00046 * Math.Sin(2 * F - 2 * D) + -0.00039 * Math.Sin(Mdash - F) + -0.00032 * Math.Sin(Mdash - M - D) + 0.00027 * Math.Sin(2 * Mdash - M - 2 * D) + 0.00023 * Math.Sin(K2) + -0.00014 * Math.Sin(2 * D) + 0.00014 * Math.Cos(2 * Mdash - 2 * F) + -0.00012 * Math.Sin(Mdash - 2 * F) + -0.00012 * Math.Sin(2 * Mdash) + 0.00011 * Math.Sin(2 * Mdash - 2 * M - 2 * D);

        ldash2 = -tau + (rho * Math.Cos(A) + sigma * Math.Sin(A)) * Math.Tan(bdash);
        bdash  = CAACoordinateTransformation.RadiansToDegrees(bdash);
        bdash2 = sigma * Math.Cos(A) - rho * Math.Sin(A);
    }
Beispiel #18
0
    public static double AltitudeOfSun(double JD, double Longitude, double Latitude)
    {
        //Calculate the selenographic details
        CAASelenographicMoonDetails selenographicDetails = CalculateSelenographicPositionOfSun(JD);

        //convert to radians
        Latitude  = CAACoordinateTransformation.DegreesToRadians(Latitude);
        Longitude = CAACoordinateTransformation.DegreesToRadians(Longitude);
        selenographicDetails.b0 = CAACoordinateTransformation.DegreesToRadians(selenographicDetails.b0);
        selenographicDetails.c0 = CAACoordinateTransformation.DegreesToRadians(selenographicDetails.c0);

        return(CAACoordinateTransformation.RadiansToDegrees(Math.Asin(Math.Sin(selenographicDetails.b0) * Math.Sin(Latitude) + Math.Cos(selenographicDetails.b0) * Math.Cos(Latitude) * Math.Sin(selenographicDetails.c0 + Longitude))));
    }
Beispiel #19
0
//Static methods

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

    public static double GeocentricElongation(double ObjectAlpha, double ObjectDelta, double SunAlpha, double SunDelta)
    {
        //Convert the RA's to radians
        ObjectAlpha = CAACoordinateTransformation.DegreesToRadians(ObjectAlpha * 15);
        SunAlpha    = CAACoordinateTransformation.DegreesToRadians(SunAlpha * 15);

        //Convert the declinations to radians
        ObjectDelta = CAACoordinateTransformation.DegreesToRadians(ObjectDelta);
        SunDelta    = CAACoordinateTransformation.DegreesToRadians(SunDelta);

        //Return the result
        return(CAACoordinateTransformation.RadiansToDegrees(Math.Acos(Math.Sin(SunDelta) * Math.Sin(ObjectDelta) + Math.Cos(SunDelta) * Math.Cos(ObjectDelta) * Math.Cos(SunAlpha - ObjectAlpha))));
    }
Beispiel #20
0
//C++ TO C# CONVERTER NOTE: C# does not allow default values for parameters. Overloaded methods are inserted above.
//ORIGINAL LINE: static double Calculate(double M, double e, int nIterations = 53)
    public static double Calculate(double M, double e, int nIterations)
    {
        //Convert from degrees to radians
        M = CAACoordinateTransformation.DegreesToRadians(M);
        double PI = CAACoordinateTransformation.PI();

        double F = 1;

        if (M < 0)
        {
            F = -1;
        }
        M = Math.Abs(M) / (2 * PI);
        M = (M - (int)(M)) * 2 * PI * F;
        if (M < 0)
        {
            M += 2 * PI;
        }
        F = 1;
        if (M > PI)
        {
            F = -1;
        }
        if (M > PI)
        {
            M = 2 * PI - M;
        }

        double E     = PI / 2;
        double scale = PI / 4;

        for (int i = 0; i < nIterations; i++)
        {
            double R = E - e * Math.Sin(E);
            if (M > R)
            {
                E += scale;
            }
            else
            {
                E -= scale;
            }
            scale /= 2;
        }

        //Convert the result back to degrees
        return(CAACoordinateTransformation.RadiansToDegrees(E) * F);
    }
Beispiel #21
0
    public static double TopocentricMoonSemidiameter(double DistanceDelta, double Delta, double H, double Latitude, double Height)
    {
        //Convert to radians
        H     = CAACoordinateTransformation.HoursToRadians(H);
        Delta = CAACoordinateTransformation.DegreesToRadians(Delta);

        double pi = Math.Asin(6378.14 / DistanceDelta);
        double A  = Math.Cos(Delta) * Math.Sin(H);
        double B  = Math.Cos(Delta) * Math.Cos(H) - CAAGlobe.RhoCosThetaPrime(Latitude, Height) * Math.Sin(pi);
        double C  = Math.Sin(Delta) - CAAGlobe.RhoSinThetaPrime(Latitude, Height) * Math.Sin(pi);
        double q  = Math.Sqrt(A * A + B * B + C * C);

        double s = CAACoordinateTransformation.DegreesToRadians(GeocentricMoonSemidiameter(DistanceDelta) / 3600);

        return(CAACoordinateTransformation.RadiansToDegrees(Math.Asin(Math.Sin(s) / q)) * 3600);
    }
    public static CAANodeObjectDetails PassageThroDescendingNode(CAAEllipticalObjectElements elements)
    {
        double v = CAACoordinateTransformation.MapTo0To360Range(180 - elements.w);

        v = CAACoordinateTransformation.DegreesToRadians(v);
        double E = Math.Atan(Math.Sqrt((1 - elements.e) / (1 + elements.e)) * Math.Tan(v / 2)) * 2;
        double M = E - elements.e * Math.Sin(E);

        M = CAACoordinateTransformation.RadiansToDegrees(M);
        double n = CAAElliptical.MeanMotionFromSemiMajorAxis(elements.a);

        CAANodeObjectDetails details = new CAANodeObjectDetails();

        details.t      = elements.T + M / n;
        details.radius = elements.a * (1 - elements.e * Math.Cos(E));

        return(details);
    }
Beispiel #23
0
    public static CAATopocentricEclipticDetails Ecliptic2Topocentric(double Lambda, double Beta, double Semidiameter, double Distance, double Epsilon, double Longitude, double Latitude, double Height, double JD)
    {
        double S = CAAGlobe.RhoSinThetaPrime(Latitude, Height);
        double C = CAAGlobe.RhoCosThetaPrime(Latitude, Height);

        //Convert to radians
        Lambda       = CAACoordinateTransformation.DegreesToRadians(Lambda);
        Beta         = CAACoordinateTransformation.DegreesToRadians(Beta);
        Epsilon      = CAACoordinateTransformation.DegreesToRadians(Epsilon);
        Longitude    = CAACoordinateTransformation.DegreesToRadians(Longitude);
        Latitude     = CAACoordinateTransformation.DegreesToRadians(Latitude);
        Semidiameter = CAACoordinateTransformation.DegreesToRadians(Semidiameter);
        double sine    = Math.Sin(Epsilon);
        double cose    = Math.Cos(Epsilon);
        double cosBeta = Math.Cos(Beta);
        double sinBeta = Math.Sin(Beta);

        //Calculate the Sidereal time
        double theta = CAASidereal.ApparentGreenwichSiderealTime(JD);

        theta = CAACoordinateTransformation.HoursToRadians(theta);
        double sintheta = Math.Sin(theta);

        //Calculate the Parallax
        double pi    = Math.Asin(GlobalMembersStdafx.g_AAParallax_C1 / Distance);
        double sinpi = Math.Sin(pi);

        double N = Math.Cos(Lambda) * cosBeta - C * sinpi * Math.Cos(theta);

        CAATopocentricEclipticDetails Topocentric = new CAATopocentricEclipticDetails();

        Topocentric.Lambda = Math.Atan2(Math.Sin(Lambda) * cosBeta - sinpi * (S * sine + C * cose * sintheta), N);
        double cosTopocentricLambda = Math.Cos(Topocentric.Lambda);

        Topocentric.Beta         = Math.Atan(cosTopocentricLambda * (sinBeta - sinpi * (S * cose - C * sine * sintheta)) / N);
        Topocentric.Semidiameter = Math.Asin(cosTopocentricLambda * Math.Cos(Topocentric.Beta) * Math.Sin(Semidiameter) / N);

        //Convert back to degrees
        Topocentric.Semidiameter = CAACoordinateTransformation.RadiansToDegrees(Topocentric.Semidiameter);
        Topocentric.Lambda       = CAACoordinateTransformation.MapTo0To360Range(CAACoordinateTransformation.RadiansToDegrees(Topocentric.Lambda));
        Topocentric.Beta         = CAACoordinateTransformation.RadiansToDegrees(Topocentric.Beta);

        return(Topocentric);
    }
Beispiel #24
0
    public static CAA2DCoordinate EquatorialAberration(double Alpha, double Delta, double JD)
    {
        //Convert to radians
        Alpha = CAACoordinateTransformation.DegreesToRadians(Alpha * 15);
        Delta = CAACoordinateTransformation.DegreesToRadians(Delta);

        double cosAlpha = Math.Cos(Alpha);
        double sinAlpha = Math.Sin(Alpha);
        double cosDelta = Math.Cos(Delta);
        double sinDelta = Math.Sin(Delta);

        CAA3DCoordinate velocity = EarthVelocity(JD);

        //What is the return value
        CAA2DCoordinate aberration = new CAA2DCoordinate();

        aberration.X = CAACoordinateTransformation.RadiansToHours((velocity.Y * cosAlpha - velocity.X * sinAlpha) / (17314463350.0 * cosDelta));
        aberration.Y = CAACoordinateTransformation.RadiansToDegrees(-(((velocity.X * cosAlpha + velocity.Y * sinAlpha) * sinDelta - velocity.Z * cosDelta) / 17314463350.0));

        return(aberration);
    }
Beispiel #25
0
    public static CAA2DCoordinate 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 = CAACoordinateTransformation.DegreesToRadians(Lambda);
        Beta   = CAACoordinateTransformation.DegreesToRadians(Beta);

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

        eta = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, eta));

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

        pi = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, pi));

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

        p = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(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);

        CAA2DCoordinate @value = new CAA2DCoordinate();

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

        return(@value);
    }
Beispiel #26
0
    //Static methods

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

    public static double Separation(double Alpha1, double Delta1, double Alpha2, double Delta2)
    {
        Delta1 = CAACoordinateTransformation.DegreesToRadians(Delta1);
        Delta2 = CAACoordinateTransformation.DegreesToRadians(Delta2);

        Alpha1 = CAACoordinateTransformation.HoursToRadians(Alpha1);
        Alpha2 = CAACoordinateTransformation.HoursToRadians(Alpha2);

        double x = Math.Cos(Delta1) * Math.Sin(Delta2) - Math.Sin(Delta1) * Math.Cos(Delta2) * Math.Cos(Alpha2 - Alpha1);
        double y = Math.Cos(Delta2) * Math.Sin(Alpha2 - Alpha1);
        double z = Math.Sin(Delta1) * Math.Sin(Delta2) + Math.Cos(Delta1) * Math.Cos(Delta2) * Math.Cos(Alpha2 - Alpha1);

        double @value = Math.Atan2(Math.Sqrt(x * x + y * y), z);

        @value = CAACoordinateTransformation.RadiansToDegrees(@value);
        if (@value < 0)
        {
            @value += 180;
        }

        return(@value);
    }
Beispiel #27
0
//Static methods
    public static CAA2DCoordinate 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 = CAACoordinateTransformation.HoursToRadians(Alpha);
        Delta = CAACoordinateTransformation.DegreesToRadians(Delta);

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

        sigma = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, sigma));

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

        zeta = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, zeta));

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

        phi = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(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);

        CAA2DCoordinate @value = new CAA2DCoordinate();

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

        return(@value);
    }
Beispiel #28
0
    public static CAA2DCoordinate 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 = CAACoordinateTransformation.HoursToRadians(Alpha);
        Delta = CAACoordinateTransformation.DegreesToRadians(Delta);

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

        sigma = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, sigma));

        double zeta = 0.791 * tsquared + 0.001 * tcubed;

        zeta  = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(0, 0, zeta));
        zeta += sigma;

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

        phi = CAACoordinateTransformation.DegreesToRadians(CAACoordinateTransformation.DMSToDegrees(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);

        CAA2DCoordinate @value = new CAA2DCoordinate();

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

        return(@value);
    }
Beispiel #29
0
    public static double PositionAngle(double alpha1, double delta1, double alpha2, double delta2)
    {
        double Alpha1;
        double Delta1;
        double Alpha2;
        double Delta2;

        Delta1 = CAACoordinateTransformation.DegreesToRadians(delta1);
        Delta2 = CAACoordinateTransformation.DegreesToRadians(delta2);

        Alpha1 = CAACoordinateTransformation.HoursToRadians(alpha1);
        Alpha2 = CAACoordinateTransformation.HoursToRadians(alpha2);

        double DeltaAlpha  = Alpha1 - Alpha2;
        double demoninator = Math.Cos(Delta2) * Math.Tan(Delta1) - Math.Sin(Delta2) * Math.Cos(DeltaAlpha);
        double numerator   = Math.Sin(DeltaAlpha);
        double @value      = Math.Atan2(numerator, demoninator);

        @value = CAACoordinateTransformation.RadiansToDegrees(@value);

        return(@value);
    }
Beispiel #30
0
    public static CAA2DCoordinate AdjustPositionUsingMotionInSpace(double r, double DeltaR, double t, double Alpha, double Delta, double PMAlpha, double PMDelta)
    {
        //Convert DeltaR from km/s to Parsecs / Year
        DeltaR /= 977792;

        //Convert from seconds of time to Radians / Year
        PMAlpha /= 13751;

        //Convert from seconds of arc to Radians / Year
        PMDelta /= 206265;

        //Now convert to radians
        Alpha = CAACoordinateTransformation.HoursToRadians(Alpha);
        Delta = CAACoordinateTransformation.DegreesToRadians(Delta);

        double x = r * Math.Cos(Delta) * Math.Cos(Alpha);
        double y = r * Math.Cos(Delta) * Math.Sin(Alpha);
        double z = r * Math.Sin(Delta);

        double DeltaX = x / r * DeltaR - z * PMDelta * Math.Cos(Alpha) - y * PMAlpha;
        double DeltaY = y / r * DeltaR - z * PMDelta * Math.Sin(Alpha) + x * PMAlpha;
        double DeltaZ = z / r * DeltaR + r * PMDelta * Math.Cos(Delta);

        x += t * DeltaX;
        y += t * DeltaY;
        z += t * DeltaZ;

        CAA2DCoordinate @value = new CAA2DCoordinate();

        @value.X = CAACoordinateTransformation.RadiansToHours(Math.Atan2(y, x));
        if (@value.X < 0)
        {
            @value.X += 24;
        }

        @value.Y = CAACoordinateTransformation.RadiansToDegrees(Math.Atan2(z, Math.Sqrt(x * x + y * y)));

        return(@value);
    }