Example #1
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);
    }
Example #2
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);
    }
Example #3
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);
    }
Example #4
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);
    }
Example #5
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);
    }
Example #6
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);
    }
Example #7
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 = CAACoordinateTransformation.DegreesToRadians(Lambda0);
        double Beta0      = 63.2818 - 0.00394 * T;
        double Beta0rad   = CAACoordinateTransformation.DegreesToRadians(Beta0);

        //Step 2
        double l0    = CAAEarth.EclipticLongitude(JD);
        double l0rad = CAACoordinateTransformation.DegreesToRadians(l0);
        double b0    = CAAEarth.EclipticLatitude(JD);
        double b0rad = CAACoordinateTransformation.DegreesToRadians(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 = CAACoordinateTransformation.DegreesToRadians(l);
            b    = CAAMars.EclipticLatitude(JD2);
            brad = CAACoordinateTransformation.DegreesToRadians(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 = CAAElliptical.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    = CAACoordinateTransformation.RadiansToDegrees(lambdarad);
        double betarad   = Math.Atan2(z, Math.Sqrt(x * x + y * y));
        double beta      = CAACoordinateTransformation.RadiansToDegrees(betarad);

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

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

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

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

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

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

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

        //Step 12
        details.w = CAACoordinateTransformation.MapTo0To360Range(W - CAACoordinateTransformation.RadiansToDegrees(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 = CAACoordinateTransformation.DegreesToRadians(Lambda0);
        lambda    += NutationInLongitude / 3600;
        lambdarad  = CAACoordinateTransformation.DegreesToRadians(lambda);
        e0        += NutationInObliquity / 3600;
        e0rad      = CAACoordinateTransformation.DegreesToRadians(e0rad);

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

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

        //Step 18
        double          SunLambda     = CAASun.GeometricEclipticLongitude(JD);
        double          SunBeta       = CAASun.GeometricEclipticLatitude(JD);
        CAA2DCoordinate SunEquatorial = CAACoordinateTransformation.Ecliptic2Equatorial(SunLambda, SunBeta, e0);

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

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

        return(details);
    }