Example #1
0
//Static methods

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

    public static double MeanGreenwichSiderealTime(double JD)
    {
        //Get the Julian day for the same day at midnight
        int    Year   = 0;
        int    Month  = 0;
        int    Day    = 0;
        int    Hour   = 0;
        int    Minute = 0;
        double Second = 0;

        CAADate date = new CAADate();

        date.Set(JD, CAADate.AfterPapalReform(JD));
        date.Get(ref Year, ref Month, ref Day, ref Hour, ref Minute, ref Second);
        date.Set(Year, Month, Day, 0, 0, 0, date.InGregorianCalendar());
        double JDMidnight = date.Julian();

        //Calculate the sidereal time at midnight
        double T        = (JDMidnight - 2451545) / 36525;
        double TSquared = T * T;
        double TCubed   = TSquared * T;
        double Value    = 100.46061837 + (36000.770053608 * T) + (0.000387933 * TSquared) - (TCubed / 38710000);

        //Adjust by the time of day
        Value += (((Hour * 15) + (Minute * 0.25) + (Second * 0.0041666666666666666666666666666667)) * 1.00273790935);

        Value = CAACoordinateTransformation.DegreesToHours(Value);

        return(CAACoordinateTransformation.MapTo0To24Range(Value));
    }
Example #2
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 #3
0
    public static double ApparentGreenwichSiderealTime(double JD)
    {
        double MeanObliquity       = CAANutation.MeanObliquityOfEcliptic(JD);
        double TrueObliquity       = MeanObliquity + CAANutation.NutationInObliquity(JD) / 3600;
        double NutationInLongitude = CAANutation.NutationInLongitude(JD);

        double Value = MeanGreenwichSiderealTime(JD) + (NutationInLongitude * Math.Cos(CAACoordinateTransformation.DegreesToRadians(TrueObliquity)) / 54000);

        return(CAACoordinateTransformation.MapTo0To24Range(Value));
    }
Example #4
0
//Static methods
    public static CAANearParabolicObjectDetails Calculate(double JD, CAANearParabolicObjectElements elements)
    {
        double Epsilon = CAANutation.MeanObliquityOfEcliptic(elements.JDEquinox);

        double JD0 = JD;

        //What will be the return value
        CAANearParabolicObjectDetails details = new CAANearParabolicObjectDetails();

        Epsilon = CAACoordinateTransformation.DegreesToRadians(Epsilon);
        double omega = CAACoordinateTransformation.DegreesToRadians(elements.omega);
        double w     = CAACoordinateTransformation.DegreesToRadians(elements.w);
        double i     = CAACoordinateTransformation.DegreesToRadians(elements.i);

        double sinEpsilon = Math.Sin(Epsilon);
        double cosEpsilon = Math.Cos(Epsilon);
        double sinOmega   = Math.Sin(omega);
        double cosOmega   = Math.Cos(omega);
        double cosi       = Math.Cos(i);
        double sini       = Math.Sin(i);

        double F = cosOmega;
        double G = sinOmega * cosEpsilon;
        double H = sinOmega * sinEpsilon;
        double P = -sinOmega * cosi;
        double Q = cosOmega * cosi * cosEpsilon - sini * sinEpsilon;
        double R = cosOmega * cosi * sinEpsilon + sini * cosEpsilon;
        double a = Math.Sqrt(F * F + P * P);
        double b = Math.Sqrt(G * G + Q * Q);
        double c = Math.Sqrt(H * H + R * R);
        double A = Math.Atan2(F, P);
        double B = Math.Atan2(G, Q);
        double C = Math.Atan2(H, R);

        CAA3DCoordinate SunCoord = CAASun.EquatorialRectangularCoordinatesAnyEquinox(JD, elements.JDEquinox);

        for (int j = 0; j < 2; j++)
        {
            double v = 0;
            double r = 0;
            CalulateTrueAnnomalyAndRadius(JD0, elements, ref v, ref r);

            double x = r * a * Math.Sin(A + w + v);
            double y = r * b * Math.Sin(B + w + v);
            double z = r * c * Math.Sin(C + w + v);

            if (j == 0)
            {
                details.HeliocentricRectangularEquatorial.X = x;
                details.HeliocentricRectangularEquatorial.Y = y;
                details.HeliocentricRectangularEquatorial.Z = z;

                //Calculate the heliocentric ecliptic coordinates also
                double u    = omega + v;
                double cosu = Math.Cos(u);
                double sinu = Math.Sin(u);

                details.HeliocentricRectangularEcliptical.X = r * (cosOmega * cosu - sinOmega * sinu * cosi);
                details.HeliocentricRectangularEcliptical.Y = r * (sinOmega * cosu + cosOmega * sinu * cosi);
                details.HeliocentricRectangularEcliptical.Z = r * sini * sinu;

                details.HeliocentricEclipticLongitude = Math.Atan2(y, x);
                details.HeliocentricEclipticLongitude = CAACoordinateTransformation.MapTo0To24Range(CAACoordinateTransformation.RadiansToDegrees(details.HeliocentricEclipticLongitude) / 15);
                details.HeliocentricEclipticLatitude  = Math.Asin(z / r);
                details.HeliocentricEclipticLatitude  = CAACoordinateTransformation.RadiansToDegrees(details.HeliocentricEclipticLatitude);
            }

            double psi   = SunCoord.X + x;
            double nu    = SunCoord.Y + y;
            double sigma = SunCoord.Z + z;

            double Alpha = Math.Atan2(nu, psi);
            Alpha = CAACoordinateTransformation.RadiansToDegrees(Alpha);
            double Delta = Math.Atan2(sigma, Math.Sqrt(psi * psi + nu * nu));
            Delta = CAACoordinateTransformation.RadiansToDegrees(Delta);
            double Distance = Math.Sqrt(psi * psi + nu * nu + sigma * sigma);

            if (j == 0)
            {
                details.TrueGeocentricRA          = CAACoordinateTransformation.MapTo0To24Range(Alpha / 15);
                details.TrueGeocentricDeclination = Delta;
                details.TrueGeocentricDistance    = Distance;
                details.TrueGeocentricLightTime   = CAAElliptical.DistanceToLightTime(Distance);
            }
            else
            {
                details.AstrometricGeocenticRA           = CAACoordinateTransformation.MapTo0To24Range(Alpha / 15);
                details.AstrometricGeocentricDeclination = Delta;
                details.AstrometricGeocentricDistance    = Distance;
                details.AstrometricGeocentricLightTime   = CAAElliptical.DistanceToLightTime(Distance);

                double RES = Math.Sqrt(SunCoord.X * SunCoord.X + SunCoord.Y * SunCoord.Y + SunCoord.Z * SunCoord.Z);

                details.Elongation = CAACoordinateTransformation.RadiansToDegrees(Math.Acos((RES * RES + Distance * Distance - r * r) / (2 * RES * Distance)));
                details.PhaseAngle = CAACoordinateTransformation.RadiansToDegrees(Math.Acos((r * r + Distance * Distance - RES * RES) / (2 * r * Distance)));
            }

            if (j == 0) //Prepare for the next loop around
            {
                JD0 = JD - details.TrueGeocentricLightTime;
            }
        }

        return(details);
    }