Ejemplo n.º 1
0
        public static AAS2DCoordinate Equatorial2Topocentric(double Alpha, double Delta, double Distance, double Longitude, double Latitude, double Height, double JD)
        {
            double RhoSinThetaPrime = AASGlobe.RhoSinThetaPrime(Latitude, Height);
            double RhoCosThetaPrime = AASGlobe.RhoCosThetaPrime(Latitude, Height);

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

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

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

            //Calculate the hour angle
            double H    = AASCoordinateTransformation.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);

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

            return(Topocentric);
        }
Ejemplo n.º 2
0
        public static AAS2DCoordinate Equatorial2TopocentricDelta(double Alpha, double Delta, double Distance, double Longitude, double Latitude, double Height, double JD)
        {
            double RhoSinThetaPrime = AASGlobe.RhoSinThetaPrime(Latitude, Height);
            double RhoCosThetaPrime = AASGlobe.RhoCosThetaPrime(Latitude, Height);

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

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

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

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

            AAS2DCoordinate DeltaTopocentric = new AAS2DCoordinate {
                X = AASCoordinateTransformation.RadiansToHours(-pi * RhoCosThetaPrime * sinH / cosDelta), Y = AASCoordinateTransformation.RadiansToDegrees(-pi * (RhoSinThetaPrime * cosDelta - RhoCosThetaPrime * cosH * Math.Sin(Delta)))
            };

            return(DeltaTopocentric);
        }
        public static AASRiseTransitSetDetails Calculate(double JD, double Alpha1, double Delta1, double Alpha2, double Delta2, double Alpha3, double Delta3, double Longitude, double Latitude, double h0)
        {
            //What will be the return value
            AASRiseTransitSetDetails details = new AASRiseTransitSetDetails();

            details.bRiseValid           = false;
            details.bSetValid            = false;
            details.bTransitValid        = true;
            details.bTransitAboveHorizon = false;

            //Calculate the sidereal time
            double theta0 = AASSidereal.ApparentGreenwichSiderealTime(JD);

            theta0 *= 15; //Express it as degrees

            //Calculate deltat
            double deltaT = AASDynamicalTime.DeltaT(JD);

            //Convert values to radians
            double Delta2Rad   = AASCoordinateTransformation.DegreesToRadians(Delta2);
            double LatitudeRad = AASCoordinateTransformation.DegreesToRadians(Latitude);

            //Convert the standard latitude to radians
            double h0Rad = AASCoordinateTransformation.DegreesToRadians(h0);

            //Calculate cosH0
            double cosH0 = (Math.Sin(h0Rad) - Math.Sin(LatitudeRad) * Math.Sin(Delta2Rad)) / (Math.Cos(LatitudeRad) * Math.Cos(Delta2Rad));

            //Calculate M0
            double M0 = CalculateTransit(Alpha2, theta0, Longitude);

            //Calculate M1 & M2
            double M1 = 0;
            double M2 = 0;

            CalculateRiseSet(M0, cosH0, ref details, ref M1, ref M2);

            //Ensure the RA values are corrected for interpolation. Due to important Remark 2 by Meeus on Interopolation of RA values
            CorrectRAValuesForInterpolation(ref Alpha1, ref Alpha2, ref Alpha3);

            //Do the main work
            CalculateTransitHelper(ref details, theta0, deltaT, Alpha1, Alpha2, Alpha3, Longitude, ref M0);
            CalculateRiseHelper(ref details, theta0, deltaT, Alpha1, Delta1, Alpha2, Delta2, Alpha3, Delta3, Longitude, Latitude, LatitudeRad, h0, ref M1);
            CalculateSetHelper(ref details, theta0, deltaT, Alpha1, Delta1, Alpha2, Delta2, Alpha3, Delta3, Longitude, Latitude, LatitudeRad, h0, ref M2);

            details.Rise    = details.bRiseValid ? (M1 * 24) : 0.0;
            details.Set     = details.bSetValid ? (M2 * 24) : 0.0;
            details.Transit = details.bTransitValid ? (M0 * 24) : 0.0;

            return(details);
        }
Ejemplo n.º 4
0
        public static AASTopocentricEclipticDetails Ecliptic2Topocentric(double Lambda, double Beta, double Semidiameter, double Distance, double Epsilon, double Latitude, double Height, double JD)
        {
            double S = AASGlobe.RhoSinThetaPrime(Latitude, Height);
            double C = AASGlobe.RhoCosThetaPrime(Latitude, Height);

            //Convert to radians
            Lambda       = AASCoordinateTransformation.DegreesToRadians(Lambda);
            Beta         = AASCoordinateTransformation.DegreesToRadians(Beta);
            Epsilon      = AASCoordinateTransformation.DegreesToRadians(Epsilon);
            Semidiameter = AASCoordinateTransformation.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 = AASSidereal.ApparentGreenwichSiderealTime(JD);

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

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

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

            AASTopocentricEclipticDetails Topocentric = new AASTopocentricEclipticDetails {
                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 = AASCoordinateTransformation.RadiansToDegrees(Topocentric.Semidiameter);
            Topocentric.Lambda       = AASCoordinateTransformation.MapTo0To360Range(AASCoordinateTransformation.RadiansToDegrees(Topocentric.Lambda));
            Topocentric.Beta         = AASCoordinateTransformation.RadiansToDegrees(Topocentric.Beta);

            return(Topocentric);
        }
Ejemplo n.º 5
0
        public static AASPhysicalMoonDetails CalculateTopocentric(double JD, double Longitude, double Latitude)
        {
            //First convert to radians
            Longitude = AASCoordinateTransformation.DegreesToRadians(Longitude);
            Latitude  = AASCoordinateTransformation.DegreesToRadians(Latitude);

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

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

            double AST = AASSidereal.ApparentGreenwichSiderealTime(JD);
            double H   = AASCoordinateTransformation.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 = AASCoordinateTransformation.DegreesToRadians(details.P);

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

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

            details.b += DeltaB;
            double DeltaP = DeltaL * Math.Sin(AASCoordinateTransformation.DegreesToRadians(details.b)) - pidash * Math.Sin(Q) * Math.Tan(Delta);

            details.P += DeltaP;

            return(details);
        }
Ejemplo n.º 6
0
        public static AASRiseTransitSetDetails Calculate(double JD, double Alpha1, double Delta1, double Alpha2, double Delta2, double Alpha3, double Delta3, double Longitude, double Latitude, double h0)
        {
            //What will be the return value
            AASRiseTransitSetDetails details = new AASRiseTransitSetDetails();

            details.bRiseValid           = false;
            details.bSetValid            = false;
            details.bTransitAboveHorizon = false;

            //Calculate the sidereal time
            double theta0 = AASSidereal.ApparentGreenwichSiderealTime(JD);

            theta0 *= 15; //Express it as degrees

            //Calculate deltat
            double deltaT = AASDynamicalTime.DeltaT(JD);

            //Convert values to radians
            double Delta2Rad   = AASCoordinateTransformation.DegreesToRadians(Delta2);
            double LatitudeRad = AASCoordinateTransformation.DegreesToRadians(Latitude);

            //Convert the standard latitude to radians
            double h0Rad = AASCoordinateTransformation.DegreesToRadians(h0);

            double cosH0 = (Math.Sin(h0Rad) - Math.Sin(LatitudeRad) * Math.Sin(Delta2Rad)) / (Math.Cos(LatitudeRad) * Math.Cos(Delta2Rad));

            //Calculate and ensure the M0 is in the range 0 to +1
            double M0 = (Alpha2 * 15 + Longitude - theta0) / 360;

            while (M0 > 1)
            {
                M0 -= 1;
            }
            while (M0 < 0)
            {
                M0 += 1;
            }

            //Check that the object actually rises
            double M1 = 0;
            double M2 = 0;

            if ((cosH0 > -1) && (cosH0 < 1))
            {
                details.bRiseValid           = true;
                details.bSetValid            = true;
                details.bTransitAboveHorizon = true;

                double H0 = Math.Acos(cosH0);
                H0 = AASCoordinateTransformation.RadiansToDegrees(H0);

                //Calculate and ensure the M1 and M2 is in the range 0 to +1
                M1 = M0 - H0 / 360;
                M2 = M0 + H0 / 360;

                while (M1 > 1)
                {
                    M1 -= 1;
                }
                while (M1 < 0)
                {
                    M1 += 1;
                }

                while (M2 > 1)
                {
                    M2 -= 1;
                }
                while (M2 < 0)
                {
                    M2 += 1;
                }
            }
            else
            if (cosH0 < 1)
            {
                details.bTransitAboveHorizon = true;
            }

            //Ensure the RA values are corrected for interpolation. Due to important Remark 2 by Meeus on Interopolation of RA values
            if ((Alpha2 - Alpha1) > 12.0)
            {
                Alpha1 += 24;
            }
            else
            if ((Alpha2 - Alpha1) < -12.0)
            {
                Alpha2 += 24;
            }
            if ((Alpha3 - Alpha2) > 12.0)
            {
                Alpha2 += 24;
            }
            else
            if ((Alpha3 - Alpha2) < -12.0)
            {
                Alpha3 += 24;
            }

            for (int i = 0; i < 2; i++)
            {
                //Calculate the details of rising
                if (details.bRiseValid)
                {
                    double theta1 = theta0 + 360.985647 * M1;
                    theta1 = AASCoordinateTransformation.MapTo0To360Range(theta1);

                    double n = M1 + deltaT / 86400;

                    double Alpha = AASInterpolate.Interpolate(n, Alpha1, Alpha2, Alpha3);
                    double Delta = AASInterpolate.Interpolate(n, Delta1, Delta2, Delta3);

                    double          H          = theta1 - Longitude - Alpha * 15;
                    AAS2DCoordinate Horizontal = AASCoordinateTransformation.Equatorial2Horizontal(H / 15, Delta, Latitude);

                    double DeltaM = (Horizontal.Y - h0) / (360 * Math.Cos(AASCoordinateTransformation.DegreesToRadians(Delta)) * Math.Cos(LatitudeRad) * Math.Sin(AASCoordinateTransformation.DegreesToRadians(H)));
                    M1 += DeltaM;
                }

                //Calculate the details of setting
                if (details.bSetValid)
                {
                    double theta1 = theta0 + 360.985647 * M2;
                    theta1 = AASCoordinateTransformation.MapTo0To360Range(theta1);

                    double n = M2 + deltaT / 86400;

                    double Alpha = AASInterpolate.Interpolate(n, Alpha1, Alpha2, Alpha3);
                    double Delta = AASInterpolate.Interpolate(n, Delta1, Delta2, Delta3);

                    double          H          = theta1 - Longitude - Alpha * 15;
                    AAS2DCoordinate Horizontal = AASCoordinateTransformation.Equatorial2Horizontal(H / 15, Delta, Latitude);

                    double DeltaM = (Horizontal.Y - h0) / (360 * Math.Cos(AASCoordinateTransformation.DegreesToRadians(Delta)) * Math.Cos(LatitudeRad) * Math.Sin(AASCoordinateTransformation.DegreesToRadians(H)));
                    M2 += DeltaM;
                }

                {
                    //Calculate the details of transit
                    double theta1 = theta0 + 360.985647 * M0;
                    theta1 = AASCoordinateTransformation.MapTo0To360Range(theta1);

                    double n = M0 + deltaT / 86400;

                    double Alpha = AASInterpolate.Interpolate(n, Alpha1, Alpha2, Alpha3);

                    double H = theta1 - Longitude - Alpha * 15;
                    H = AASCoordinateTransformation.MapTo0To360Range(H);
                    if (H > 180)
                    {
                        H -= 360;
                    }

                    double DeltaM = -H / 360;
                    M0 += DeltaM;
                }
            }

            details.Rise    = details.bRiseValid ? (M1 * 24) : 0.0;
            details.Set     = details.bSetValid ? (M2 * 24) : 0.0;
            details.Transit = M0 * 24; //We always return the transit time even if it occurs below the horizon

            return(details);
        }