Ejemplo n.º 1
0
        // Degrees per radian
        static void Main0(string[] args)
        {
            // Position and velocity
            Geo.Algorithm.Vector r = new Geo.Algorithm.Vector(+10000.0e3, +40000.0e3, -5000.0e3); // [m]
            Geo.Algorithm.Vector v = new Geo.Algorithm.Vector(-1.500e3, +1.000e3, -0.100e3);      // [m/s]

            // Variables
            int i;

            Geo.Algorithm.Vector y = new Geo.Algorithm.Vector(6), Kep = new Geo.Algorithm.Vector(6);

            // Orbital elements
            y = r.Stack(v);

            Kep = Kepler.Elements(OrbitConsts.GM_Earth, y);

            // Output
            var info = "Exercise 2-3: Osculating elements";

            Console.WriteLine(info);

            info = "State vector:";
            Console.WriteLine(info);
            info = "  Position       ";
            Console.Write(info);
            for (i = 0; i < 3; i++)
            {
                Console.Write(r[i] / 1000.0 + ", ");
                //Console.WriteLine(info);
            }
            ;

            info = "  [km]";
            Console.WriteLine(info);

            info = "  Velocity       ";
            Console.Write(info);
            for (i = 0; i < 3; i++)
            {
                Console.Write(v[i] / 1000.0 + ", ");
            }
            Console.WriteLine("  [km/s]");

            Console.WriteLine();
            Console.WriteLine("Orbital elements:");
            Console.WriteLine("  Semimajor axis   " + String.Format("{0:f3}", (Kep[0] / 1000.0)) + " km");
            Console.WriteLine("  Eccentricity     " + String.Format("{0:f3}", Kep[1]));
            Console.WriteLine("  Inclination      " + String.Format("{0:f3}", Kep[2] * OrbitConsts.DegPerRad) + " deg");
            Console.WriteLine("  RA ascend. node  " + String.Format("{0:f3}", Kep[3] * OrbitConsts.DegPerRad) + " deg");
            Console.WriteLine("  Arg. of perigee  " + String.Format("{0:f3}", Kep[4] * OrbitConsts.DegPerRad) + " deg");
            Console.WriteLine("  Mean anomaly     " + String.Format("{0:f3}", Kep[5] * OrbitConsts.DegPerRad) + " deg");

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        static void Main0(string[] args)
        {
            // Variables

            int    i;                                               // Loop counter
            double MJD_GPS, MJD_TT;                                 // Modified Julian Date (GPS,TT)
            double MJD_UTC, MJD_UT1;                                // Modified Julian Date (UTC,UT1)
            Matrix P = new Matrix(3, 3), N = new Matrix(3, 3);      // Precession/nutation matrix
            Matrix Theta = new Matrix(3, 3);                        // Sidereal Time matrix
            Matrix S = new Matrix(3, 3), dTheta = new Matrix(3, 3); // and derivative
            Matrix Pi = new Matrix(3, 3);                           // Polar motion matrix
            Matrix U = new Matrix(3, 3), dU = new Matrix(3, 3);     // ICRS to ITRS transformation and derivative
            Vector r_WGS = new Vector(3), v_WGS = new Vector(3);    // Position/velocity in the Earth-fixed frame
            Vector r = new Vector(3), v = new Vector(3);            // Position/velocity in the ICRS
            Vector y = new Vector(6), Kep = new Vector(6);          // Satte vector and Keplerian elements


            // Header
            var endl = "\r\n";
            var info = "Exercise 5-2: Velocity in the Earth-fixed frame"
                       + endl + endl;

            Console.WriteLine(info);

            // Earth Orientation Parameters (UT1-UTC[s],UTC-TAI[s], x["], y["])
            // (from IERS Bulletin B #135 and C #16; valid for 1999/03/04 0:00 UTC)

            IERS IERS = new IERS(0.6492332, -32.0, 0.06740, 0.24173);

            // Date

            MJD_GPS = DateUtil.DateToMjd(1999, 03, 04, 0, 0, 0.0);

            MJD_UTC = MJD_GPS - IERS.GetGPS_UTC(MJD_GPS) / 86400.0;
            MJD_UT1 = MJD_UTC + IERS.GetUT1_UTC(MJD_UTC) / 86400.0;
            MJD_TT  = MJD_UTC + IERS.GetTT_UTC(MJD_UTC) / 86400.0;

            // Earth-fixed state vector of GPS satellite #PRN15
            // (from NIMA ephemeris nim09994.eph; WGS84(G873) system)

            r_WGS = new Vector(19440.953805e+3, 16881.609273e+3, -6777.115092e+3);  // [m]
            v_WGS = new Vector(-8111.827456e-1, -2573.799137e-1, -30689.508125e-1); // [m/s]


            // ICRS to ITRS transformation matrix and derivative

            P     = IERS.PrecessionMatrix(OrbitConsts.MJD_J2000, MJD_TT); // IAU 1976 Precession
            N     = IERS.NutMatrix(MJD_TT);                               // IAU 1980 Nutation
            Theta = IERS.GreenwichHourAngleMatrix(MJD_UT1);               // Earth rotation
            Pi    = IERS.PoleMatrix(MJD_UTC);                             // Polar motion

            S[0, 1] = 1.0; S[1, 0] = -1.0;                                // Derivative of Earth rotation
            dTheta  = OrbitConsts.RotationSpeedOfEarth_Rad * S * Theta;   // matrix [1/s]

            U  = Pi * Theta * N * P;                                      // ICRS to ITRS transformation
            dU = Pi * dTheta * N * P;                                     // Derivative [1/s]

            // Transformation from WGS to ICRS

            r = U.Transpose() * r_WGS;
            v = U.Transpose() * v_WGS + dU.Transpose() * r_WGS;

            // Orbital elements

            y   = r.Stack(v);
            Kep = Kepler.Elements(OrbitConsts.GM_Earth, y);


            // Output

            info = "Date" + endl + endl
                   + " " + DateUtil.MjdToDateTimeString(MJD_GPS) + " GPS" + endl
                   + " " + DateUtil.MjdToDateTimeString(MJD_UTC) + " UTC" + endl
                   + " " + DateUtil.MjdToDateTimeString(MJD_UT1) + " UT1" + endl
                   + " " + DateUtil.MjdToDateTimeString(MJD_TT) + " TT " + endl + endl;

            Console.WriteLine(info);
            info  = "WGS84 (G873) State vector:" + endl + endl;
            info += "  Position       ";
            for (i = 0; i < 3; i++)
            {
                info += String.Format("{0, 10:F6}", r_WGS[i] / 1000.0);
            }
            ;
            info += "  [km]";
            Console.WriteLine(info);
            info = "  Velocity       ";
            for (i = 0; i < 3; i++)
            {
                info += String.Format("{0, 10:F6}", v_WGS[i] / 1000.0);
            }
            ;
            info += "  [km/s]" + endl + endl;
            Console.WriteLine(info);
            info = "ICRS-ITRS transformation" + endl + endl
                   + String.Format("{0, 10:F6}", U) + endl;

            info += "Derivative of ICRS-ITRS transformation [10^(-4)/s]" + endl + endl
                    + String.Format("{0, 10:F6}", dU * 1.0e4) + endl;

            info += "ICRS State vector:" + endl;
            Console.WriteLine(info);
            info = "  Position       ";
            for (i = 0; i < 3; i++)
            {
                info += String.Format("{0, 14:F6}", r[i] / 1000.0);
            }
            ;
            info += "  [km]";
            Console.WriteLine(info);
            info = "  Velocity       ";
            for (i = 0; i < 3; i++)
            {
                info += String.Format("{0, 14:F6}", v[i] / 1000.0);
            }
            ;
            info += "  [km/s]" + endl + endl;
            Console.WriteLine(info);
            info = "Orbital elements:" + endl + endl
                   + "  Semimajor axis   " + String.Format("{0, 10:F3}", Kep[0] / 1000.0) + " km" + endl
                   + "  Eccentricity     " + String.Format("{0, 10:F7}", Kep[1]) + endl
                   + "  Inclination      " + String.Format("{0, 10:F3}", Kep[2] * OrbitConsts.DegPerRad) + " deg" + endl
                   + "  RA ascend. node  " + String.Format("{0, 10:F3}", Kep[3] * OrbitConsts.DegPerRad) + " deg" + endl
                   + "  Arg. of perigee  " + String.Format("{0, 10:F3}", Kep[4] * OrbitConsts.DegPerRad) + " deg" + endl
                   + "  Mean anomaly     " + String.Format("{0, 10:F3}", Kep[5] * OrbitConsts.DegPerRad) + " deg" + endl;

            Console.WriteLine(info);

            Console.ReadKey();
        }
        static void Main0(string[] args)
        {
            string endl = "\r\n";

            // Ground station

            Vector   R_Sta = new Geo.Algorithm.Vector(+1344.143e3, +6068.601e3, +1429.311e3); // Position vector
            GeoCoord Sta   = CoordTransformer.XyzToGeoCoord(new XYZ(R_Sta.OneDimArray));      //new GeoCoord(R_Sta, OrbitConsts.RadiusOfEarth, OrbitConsts.FlatteningOfEarth);// Geodetic coordinates

            // Observations
            ObsType[] Obs = new ObsType[]  {
                new ObsType(DateUtil.DateToMjd(1999, 04, 02, 00, 30, 00.0), 132.67 * OrbitConsts.RadPerDeg, 32.44 * OrbitConsts.RadPerDeg, 16945.450e3),
                new ObsType(DateUtil.DateToMjd(1999, 04, 02, 03, 00, 00.0), 123.08 * OrbitConsts.RadPerDeg, 50.06 * OrbitConsts.RadPerDeg, 37350.340e3)
            };

            // Variables

            int    i, j;
            double Az, El, d;

            Geo.Algorithm.Vector   s = new Geo.Algorithm.Vector(3);
            Geo.Algorithm.Vector[] r = new Geo.Algorithm.Vector[2];

            // Transformation to local tangent coordinates
            Matrix E = Sta.ToLocalNez_Matrix();

            // Convert observations
            for (i = 0; i < 2; i++)
            {
                // Earth rotation
                Matrix U = Matrix.RotateZ3D(IERS.GetGmstRad(Obs[i].Mjd_UTC));
                // Topocentric position vector
                Az = Obs[i].Azimuth; El = Obs[i].Elevation; d = Obs[i].Range;
                s  = d * Geo.Algorithm.Vector.VecPolar(OrbitConsts.PI / 2 - Az, El);
                // Inertial position vector
                r[i] = U.Transpose() * (E.Transpose() * s + R_Sta);
            }

            // Orbital elements
            Geo.Algorithm.Vector Kep = Kepler.Elements(OrbitConsts.GM_Earth, Obs[0].Mjd_UTC, Obs[1].Mjd_UTC, r[0], r[1]);

            // Output
            var info = "Exercise 2-6: Initial orbit determination" + "\r\n";

            info += "Inertial positions:" + "\r\n";
            info += "                             ";
            info += "[km]" + "          [km]" + "          [km]";
            Console.WriteLine(info);
            for (i = 0; i < 2; i++)
            {
                info = "  " + DateUtil.MjdToDateTimeString(Obs[i].Mjd_UTC);

                for (j = 0; j < 3; j++)
                {
                    info += " " + String.Format("{0, 12:F3}", r[i][j] / 1000.0);
                }
                ;
                Console.WriteLine(info);
            }
            Console.WriteLine();

            info = "Orbital elements:" + "\r\n"
                   + "  Epoch (1st obs.)  " + DateUtil.MjdToDateTimeString(Obs[0].Mjd_UTC) + endl
                   + "  Semimajor axis   " + String.Format("{0, 10:F3}", Kep[0] / 1000.0) + " km" + endl
                   + "  Eccentricity     " + String.Format("{0, 10:F3}", Kep[1]) + endl
                   + "  Inclination      " + String.Format("{0, 10:F3}", Kep[2] * OrbitConsts.DegPerRad) + " deg" + endl
                   + "  RA ascend. node  " + String.Format("{0, 10:F3}", Kep[3] * OrbitConsts.DegPerRad) + " deg" + endl
                   + "  Arg. of perigee  " + String.Format("{0, 10:F3}", Kep[4] * OrbitConsts.DegPerRad) + " deg" + endl
                   + "  Mean anomaly     " + String.Format("{0, 10:F3}", Kep[5] * OrbitConsts.DegPerRad) + " deg" + endl;
            Console.WriteLine(info);
            Console.ReadKey();
        }