Example #1
0
//Static methods

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

    public static double MeanGreenwichSiderealTime(double JD)
    {
        //Get the Julian day for the same day at midnight

        DT date = new DT();

        date.SetJD(JD, DT.AfterPapalReformJD(JD));
        double[] D = date.Get();

        int    Year   = (int)D[0];
        int    Month  = (int)D[1];
        int    Day    = (int)D[2];
        int    Hour   = (int)D[3];
        int    Minute = (int)D[4];
        double Second = D[5];

        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 = CT.D2H(Value);

        return(CT.M24(Value));
    }
    public static COR 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 = CT.D2R(Delta);
        double cosDelta = Math.Cos(Delta);

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

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

        COR Topocentric = new COR();

        Topocentric.X = CT.M24(Alpha + CT.R2H(DeltaAlpha));
        Topocentric.Y = CT.R2D(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(CT.D2R(TrueObliquity)) / 54000);

        return(CT.M24(Value));
    }
Example #4
0
    public static CAAParabolicObjectDetails Calculate(double JD, CAAParabolicObjectElements elements)
    {
        double Epsilon = CAANutation.MeanObliquityOfEcliptic(elements.JDEquinox);

        double JD0 = JD;

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

        Epsilon = CT.D2R(Epsilon);
        double omega = CT.D2R(elements.omega);
        double w     = CT.D2R(elements.w);
        double i     = CT.D2R(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);

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

        for (int j = 0; j < 2; j++)
        {
            double W = 0.03649116245 / (elements.q * Math.Sqrt(elements.q)) * (JD0 - elements.T);
            double s = CalculateBarkers(W);
            double v = 2 * Math.Atan(s);
            double r = elements.q * (1 + s * s);
            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 = CT.M24(CT.R2D(details.HeliocentricEclipticLongitude) / 15);
                details.HeliocentricEclipticLatitude  = Math.Asin(z / r);
                details.HeliocentricEclipticLatitude  = CT.R2D(details.HeliocentricEclipticLatitude);
            }

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

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

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

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

                details.Elongation = CT.R2D(Math.Acos((RES * RES + Distance * Distance - r * r) / (2 * RES * Distance)));
                details.PhaseAngle = CT.R2D(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);
    }