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
//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))));
    }
Example #4
0
    public static double NutationInDeclination(double Alpha, double Delta, double Obliquity, double NutationInLongitude, double NutationInObliquity)
    {
        //Convert to radians
        Alpha     = CAACoordinateTransformation.HoursToRadians(Alpha);
        Delta     = CAACoordinateTransformation.DegreesToRadians(Delta);
        Obliquity = CAACoordinateTransformation.DegreesToRadians(Obliquity);

        return(Math.Sin(Obliquity) * Math.Cos(Alpha) * NutationInLongitude + Math.Sin(Alpha) * NutationInObliquity);
    }
Example #5
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)))));
    }
Example #6
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));
    }
Example #7
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));
    }
Example #8
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);
    }
Example #9
0
    public static CAA2DCoordinate EquatorialPMToEcliptic(double Alpha, double Delta, double Beta, double PMAlpha, double PMDelta, double Epsilon)
    {
        //Convert to radians
        Epsilon = CAACoordinateTransformation.DegreesToRadians(Epsilon);
        Alpha   = CAACoordinateTransformation.HoursToRadians(Alpha);
        Delta   = CAACoordinateTransformation.DegreesToRadians(Delta);
        Beta    = CAACoordinateTransformation.DegreesToRadians(Beta);

        double cosb       = Math.Cos(Beta);
        double sinEpsilon = Math.Sin(Epsilon);

        CAA2DCoordinate @value = new CAA2DCoordinate();

        @value.X = (PMDelta * sinEpsilon * Math.Cos(Alpha) + PMAlpha * Math.Cos(Delta) * (Math.Cos(Epsilon) * Math.Cos(Delta) + sinEpsilon * Math.Sin(Delta) * Math.Sin(Alpha))) / (cosb * cosb);
        @value.Y = (PMDelta * (Math.Cos(Epsilon) * Math.Cos(Delta) + sinEpsilon * Math.Sin(Delta) * Math.Sin(Alpha)) - PMAlpha * sinEpsilon * Math.Cos(Alpha) * Math.Cos(Delta)) / cosb;

        return(@value);
    }
Example #10
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);
    }
Example #11
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 #12
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);
    }
Example #13
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);
    }
Example #14
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 #15
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 #16
0
    protected static CAAPhysicalMoonDetails CalculateHelper(double JD, ref double Lambda, ref double Beta, ref double epsilon, ref CAA2DCoordinate Equatorial)
    {
        //What will be the return value
        CAAPhysicalMoonDetails details = new CAAPhysicalMoonDetails();

        //Calculate the initial quantities
        Lambda = CAAMoon.EclipticLongitude(JD);
        Beta   = CAAMoon.EclipticLatitude(JD);

        //Calculate the optical libration
        double omega  = 0;
        double DeltaU = 0;
        double sigma  = 0;
        double I      = 0;
        double rho    = 0;

        CalculateOpticalLibration(JD, Lambda, Beta, ref details.ldash, ref details.bdash, ref details.ldash2, ref details.bdash2, ref epsilon, ref omega, ref DeltaU, ref sigma, ref I, ref rho);
        double epsilonrad = CAACoordinateTransformation.DegreesToRadians(epsilon);

        //Calculate the total libration
        details.l = details.ldash + details.ldash2;
        details.b = details.bdash + details.bdash2;
        double b = CAACoordinateTransformation.DegreesToRadians(details.b);

        //Calculate the position angle
        double V     = omega + DeltaU + CAACoordinateTransformation.DegreesToRadians(sigma) / Math.Sin(I);
        double I_rho = I + CAACoordinateTransformation.DegreesToRadians(rho);
        double X     = Math.Sin(I_rho) * Math.Sin(V);
        double Y     = Math.Sin(I_rho) * Math.Cos(V) * Math.Cos(epsilonrad) - Math.Cos(I_rho) * Math.Sin(epsilonrad);
        double w     = Math.Atan2(X, Y);

        Equatorial = CAACoordinateTransformation.Ecliptic2Equatorial(Lambda, Beta, epsilon);
        double Alpha = CAACoordinateTransformation.HoursToRadians(Equatorial.X);

        details.P = CAACoordinateTransformation.RadiansToDegrees(Math.Asin(Math.Sqrt(X * X + Y * Y) * Math.Cos(Alpha - w) / (Math.Cos(b))));

        return(details);
    }
Example #17
0
    public static double DistanceFromGreatArc(double Alpha1, double Delta1, double Alpha2, double Delta2, double Alpha3, double Delta3)
    {
        Delta1 = CAACoordinateTransformation.DegreesToRadians(Delta1);
        Delta2 = CAACoordinateTransformation.DegreesToRadians(Delta2);
        Delta3 = CAACoordinateTransformation.DegreesToRadians(Delta3);

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

        double X1 = Math.Cos(Delta1) * Math.Cos(Alpha1);
        double X2 = Math.Cos(Delta2) * Math.Cos(Alpha2);

        double Y1 = Math.Cos(Delta1) * Math.Sin(Alpha1);
        double Y2 = Math.Cos(Delta2) * Math.Sin(Alpha2);

        double Z1 = Math.Sin(Delta1);
        double Z2 = Math.Sin(Delta2);

        double A = Y1 * Z2 - Z1 * Y2;
        double B = Z1 * X2 - X1 * Z2;
        double C = X1 * Y2 - Y1 * X2;

        double m = Math.Tan(Alpha3);
        double n = Math.Tan(Delta3) / Math.Cos(Alpha3);

        double @value = Math.Asin((A + B * m + C * n) / (Math.Sqrt(A * A + B * B + C * C) * Math.Sqrt(1 + m * m + n * n)));

        @value = CAACoordinateTransformation.RadiansToDegrees(@value);
        if (@value < 0)
        {
            @value = Math.Abs(@value);
        }

        return(@value);
    }
Example #18
0
    public static CAAPhysicalMoonDetails CalculateTopocentric(double JD, double Longitude, double Latitude)
    {
        //First convert to radians
        Longitude = CAACoordinateTransformation.DegreesToRadians(Longitude);
        Latitude  = CAACoordinateTransformation.DegreesToRadians(Latitude);

        double                 Lambda     = 0;
        double                 Beta       = 0;
        double                 epsilon    = 0;
        CAA2DCoordinate        Equatorial = new CAA2DCoordinate();
        CAAPhysicalMoonDetails details    = CalculateHelper(JD, ref Lambda, ref Beta, ref epsilon, ref Equatorial);

        double R     = CAAMoon.RadiusVector(JD);
        double pi    = CAAMoon.RadiusVectorToHorizontalParallax(R);
        double Alpha = CAACoordinateTransformation.HoursToRadians(Equatorial.X);
        double Delta = CAACoordinateTransformation.DegreesToRadians(Equatorial.Y);

        double AST = CAASidereal.ApparentGreenwichSiderealTime(JD);
        double H   = CAACoordinateTransformation.HoursToRadians(AST) - Longitude - Alpha;

        double Q      = Math.Atan2(Math.Cos(Latitude) * Math.Sin(H), Math.Cos(Delta) * Math.Sin(Latitude) - Math.Sin(Delta) * Math.Cos(Latitude) * Math.Cos(H));
        double Z      = Math.Acos(Math.Sin(Delta) * Math.Sin(Latitude) + Math.Cos(Delta) * Math.Cos(Latitude) * Math.Cos(H));
        double pidash = pi * (Math.Sin(Z) + 0.0084 * Math.Sin(2 * Z));

        double Prad = CAACoordinateTransformation.DegreesToRadians(details.P);

        double DeltaL = -pidash *Math.Sin(Q - Prad) / Math.Cos(CAACoordinateTransformation.DegreesToRadians(details.b));

        details.l += DeltaL;
        double DeltaB = pidash * Math.Cos(Q - Prad);

        details.b += DeltaB;
        details.P += DeltaL * Math.Sin(CAACoordinateTransformation.DegreesToRadians(details.b)) - pidash * Math.Sin(Q) * Math.Tan(Delta);

        return(details);
    }
//Static methods

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

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

        double T  = (JD - 2451545) / 36525;
        double T2 = T * T;

        //Step 1. Calculate the inclination of the plane of the ring and the longitude of the ascending node referred to the ecliptic and mean equinox of the date
        double i        = 28.075216 - 0.012998 * T + 0.000004 * T2;
        double irad     = CAACoordinateTransformation.DegreesToRadians(i);
        double omega    = 169.508470 + 1.394681 * T + 0.000412 * T2;
        double omegarad = CAACoordinateTransformation.DegreesToRadians(omega);

        //Step 2. Calculate the heliocentric longitude, latitude and radius vector of the Earth in the FK5 system
        double l0 = CAAEarth.EclipticLongitude(JD);
        double b0 = CAAEarth.EclipticLatitude(JD);

        l0 += CAAFK5.CorrectionInLongitude(l0, b0, JD);
        double l0rad = CAACoordinateTransformation.DegreesToRadians(l0);

        b0 += CAAFK5.CorrectionInLatitude(l0, JD);
        double b0rad = CAACoordinateTransformation.DegreesToRadians(b0);
        double R     = CAAEarth.RadiusVector(JD);

        //Step 3. Calculate the corresponding coordinates l,b,r for Saturn but for the instance t-lightraveltime
        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 b        = 0;
        double r        = 0;

        while (bIterate)
        {
            //Calculate the position of Saturn
            l  = CAASaturn.EclipticLongitude(JD1);
            b  = CAASaturn.EclipticLatitude(JD1);
            l += CAAFK5.CorrectionInLongitude(l, b, JD1);
            b += CAAFK5.CorrectionInLatitude(l, JD1);

            double lrad = CAACoordinateTransformation.DegreesToRadians(l);
            double brad = CAACoordinateTransformation.DegreesToRadians(b);
            r = CAASaturn.RadiusVector(JD1);

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

        //Step 5. Calculate Saturn's geocentric Longitude and Latitude
        double lambda = Math.Atan2(y, x);
        double beta   = Math.Atan2(z, Math.Sqrt(x * x + y * y));

        //Step 6. Calculate B, a and b
        details.B = Math.Asin(Math.Sin(irad) * Math.Cos(beta) * Math.Sin(lambda - omegarad) - Math.Cos(irad) * Math.Sin(beta));
        details.a = 375.35 / DELTA;
        details.b = details.a * Math.Sin(Math.Abs(details.B));
        details.B = CAACoordinateTransformation.RadiansToDegrees(details.B);

        //Step 7. Calculate the longitude of the ascending node of Saturn's orbit
        double N        = 113.6655 + 0.8771 * T;
        double Nrad     = CAACoordinateTransformation.DegreesToRadians(N);
        double ldash    = l - 0.01759 / r;
        double ldashrad = CAACoordinateTransformation.DegreesToRadians(ldash);
        double bdash    = b - 0.000764 * Math.Cos(ldashrad - Nrad) / r;
        double bdashrad = CAACoordinateTransformation.DegreesToRadians(bdash);

        //Step 8. Calculate Bdash
        details.Bdash = CAACoordinateTransformation.RadiansToDegrees(Math.Asin(Math.Sin(irad) * Math.Cos(bdashrad) * Math.Sin(ldashrad - omegarad) - Math.Cos(irad) * Math.Sin(bdashrad)));

        //Step 9. Calculate DeltaU
        double U1 = Math.Atan2(Math.Sin(irad) * Math.Sin(bdashrad) + Math.Cos(irad) * Math.Cos(bdashrad) * Math.Sin(ldashrad - omegarad), Math.Cos(bdashrad) * Math.Cos(ldashrad - omegarad));
        double U2 = Math.Atan2(Math.Sin(irad) * Math.Sin(beta) + Math.Cos(irad) * Math.Cos(beta) * Math.Sin(lambda - omegarad), Math.Cos(beta) * Math.Cos(lambda - omegarad));

        details.DeltaU = CAACoordinateTransformation.RadiansToDegrees(Math.Abs(U1 - U2));

        //Step 10. Calculate the Nutations
        double Obliquity           = CAANutation.TrueObliquityOfEcliptic(JD);
        double NutationInLongitude = CAANutation.NutationInLongitude(JD);

        //Step 11. Calculate the Ecliptical longitude and latitude of the northern pole of the ring plane
        double lambda0 = omega - 90;
        double beta0   = 90 - i;

        //Step 12. Correct lambda and beta for the aberration of Saturn
        lambda += CAACoordinateTransformation.DegreesToRadians(0.005693 * Math.Cos(l0rad - lambda) / Math.Cos(beta));
        beta   += CAACoordinateTransformation.DegreesToRadians(0.005693 * Math.Sin(l0rad - lambda) * Math.Sin(beta));

        //Step 13. Add nutation in longitude to lambda0 and lambda
        //double NLrad = CAACoordinateTransformation::DegreesToRadians(NutationInLongitude/3600);
        lambda   = CAACoordinateTransformation.RadiansToDegrees(lambda);
        lambda  += NutationInLongitude / 3600;
        lambda   = CAACoordinateTransformation.MapTo0To360Range(lambda);
        lambda0 += NutationInLongitude / 3600;
        lambda0  = CAACoordinateTransformation.MapTo0To360Range(lambda0);

        //Step 14. Convert to equatorial coordinates
        beta = CAACoordinateTransformation.RadiansToDegrees(beta);
        CAA2DCoordinate GeocentricEclipticSaturn = CAACoordinateTransformation.Ecliptic2Equatorial(lambda, beta, Obliquity);
        double          alpha = CAACoordinateTransformation.HoursToRadians(GeocentricEclipticSaturn.X);
        double          delta = CAACoordinateTransformation.DegreesToRadians(GeocentricEclipticSaturn.Y);
        CAA2DCoordinate GeocentricEclipticNorthPole = CAACoordinateTransformation.Ecliptic2Equatorial(lambda0, beta0, Obliquity);
        double          alpha0 = CAACoordinateTransformation.HoursToRadians(GeocentricEclipticNorthPole.X);
        double          delta0 = CAACoordinateTransformation.DegreesToRadians(GeocentricEclipticNorthPole.Y);

        //Step 15. Calculate the Position angle
        details.P = 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)));

        return(details);
    }
Example #20
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);
    }