Пример #1
0
        public void TestWGS84EarthAltitude()
        {
            GroundCallback cb = new DefaultGroundCallback(a, b);
            Location       loc = new Location(), contact = new Location();
            Vector3D       normal, v, w;
            Vector3D       zero = new Vector3D(0.0, 0.0, 0.0);
            double         h    = 100000.0;

            loc.SetEllipse(a, b);
            contact.SetEllipse(a, b);

            // Check that, for a point located, on the sea level radius the AGL is 0.0
            for (double lat = -90.0; lat <= 90.0; lat += 30.0)
            {
                for (double lon = 0.0; lon <= 360.0; lon += 45.0)
                {
                    double lon_rad = lon * Math.PI / 180.0;
                    double lat_rad = lat * Math.PI / 180.0;
                    loc.SetPositionGeodetic(lon_rad, lat_rad, h);
                    double agl = cb.GetAGLevel(loc, out contact, out normal, out v, out w);
                    Assert.AreEqual(h, agl, 1e-8);
                    AssertVectorEqual(v, zero);
                    AssertVectorEqual(w, zero);
                    Assert.AreEqual(normal.X, Math.Cos(lat_rad) * Math.Cos(lon_rad), tolerance);
                    Assert.AreEqual(normal.Y, Math.Cos(lat_rad) * Math.Sin(lon_rad), tolerance);
                    Assert.AreEqual(normal.Z, Math.Sin(lat_rad), tolerance);
                    Vector3D vLoc     = (Vector3D)loc - h * normal;
                    Vector3D vContact = (Vector3D)contact;
                    Assert.AreEqual(vLoc.X, vContact.X, 1e-7);
                    Assert.AreEqual(vLoc.Y, vContact.Y, 1e-7);
                    Assert.AreEqual(vLoc.Z, vContact.Z, 1e-7);
                }
            }
        }
Пример #2
0
        public void TestSphericalEarthSurface()
        {
            GroundCallback cb = new DefaultGroundCallback(RadiusReference, RadiusReference);

            Location loc, contact;
            Vector3D normal, v, w;
            Vector3D zero = new Vector3D(0.0, 0.0, 0.0);

            // Check that, for a point located, on the sea level radius the AGL is 0.0
            for (double lat = -90.0; lat <= 90.0; lat += 30.0)
            {
                for (double lon = 0.0; lon <= 360.0; lon += 45.0)
                {
                    double lon_rad = lon * Math.PI / 180.0;
                    double lat_rad = lat * Math.PI / 180.0;
                    loc = new Location(lon_rad, lat_rad, RadiusReference);
                    double agl = cb.GetAGLevel(loc, out contact, out normal, out v, out w);
                    Assert.AreEqual(0.0, agl, 1e-8);
                    AssertVectorEqual(v, zero);
                    AssertVectorEqual(w, zero);
                    Vector3D vLoc     = (Vector3D)loc;
                    Vector3D vContact = (Vector3D)contact;
                    Assert.AreEqual(vContact.Magnitude(), RadiusReference, tolerance);
                    Assert.AreEqual(vLoc.X, vContact.X, 1e-8);
                    Assert.AreEqual(vLoc.Y, vContact.Y, 1e-8);
                    Assert.AreEqual(vLoc.Z, vContact.Z, 1e-8);
                    Assert.AreEqual(normal.X, Math.Cos(lat_rad) * Math.Cos(lon_rad), tolerance);
                    Assert.AreEqual(normal.Y, Math.Cos(lat_rad) * Math.Sin(lon_rad), tolerance);
                    Assert.AreEqual(normal.Z, Math.Sin(lat_rad), tolerance);
                    vContact.Normalize();
                    AssertVectorEqual(vContact, normal);
                }
            }
        }
Пример #3
0
        public Inertial(FDMExecutive fdmex) : base(fdmex)
        {
            RadiusReference = 20925646.32546;

            Name = "Inertial";

            // Earth defaults
            double RotationRate = 0.00007292115;

            //  RotationRate    = 0.000072921151467;
            GM   = 14.0764417572E15;   // WGS84 value
            C2_0 = -4.84165371736E-04; // WGS84 value for the C2,0 coefficient
            J2   = 1.08262982E-03;     // WGS84 value for J2
            a    = 20925646.32546;     // WGS84 semimajor axis length in feet
                                       //  a               = 20902254.5305;      // Effective Earth radius for a sphere
            b        = 20855486.5951;  // WGS84 semiminor axis length in feet
            gravType = eGravType.gtWGS84;

            // Lunar defaults

            /*
             * double RotationRate    = 0.0000026617;
             * GM              = 1.7314079E14;         // Lunar GM
             * RadiusReference = 5702559.05;           // Equatorial radius
             * C2_0            = 0;                    // value for the C2,0 coefficient
             * J2              = 2.033542482111609E-4; // value for J2
             * a               = 5702559.05;           // semimajor axis length in feet
             * b               = 5695439.63;           // semiminor axis length in feet
             */

            vOmegaPlanet   = new Vector3D(0.0, 0.0, RotationRate);
            GroundCallback = new DefaultGroundCallback(RadiusReference, RadiusReference);

            Bind();

            Debug(0);
        }
Пример #4
0
        public void TestSphericalEarthAltitudeWithTerrainElevation()
        {
            GroundCallback cb = new DefaultGroundCallback(RadiusReference, RadiusReference);
            Location       loc, contact;
            Vector3D       normal, v, w;
            Vector3D       zero      = new Vector3D(0.0, 0.0, 0.0);
            double         h         = 100000.0;
            double         elevation = 2000.0;

            cb.SetTerrainElevation(elevation);

            // Check that, for a point located, on the sea level radius the AGL is 0.0
            for (double lat = -90.0; lat <= 90.0; lat += 30.0)
            {
                for (double lon = 0.0; lon <= 360.0; lon += 45.0)
                {
                    double lon_rad = lon * Math.PI / 180.0;
                    double lat_rad = lat * Math.PI / 180.0;
                    loc = new Location(lon_rad, lat_rad, RadiusReference + h);
                    double agl = cb.GetAGLevel(loc, out contact, out normal, out v, out w);
                    Assert.AreEqual((h - elevation) / agl, 1.0, tolerance * 100.0);
                    AssertVectorEqual(v, zero);
                    AssertVectorEqual(w, zero);
                    Vector3D vLoc     = (Vector3D)loc;
                    Vector3D vContact = (Vector3D)contact;
                    Assert.AreEqual(vContact.Magnitude() / (RadiusReference + elevation), 1.0,
                                    tolerance);
                    AssertVectorEqual(vLoc / (RadiusReference + h),
                                      vContact / (RadiusReference + elevation));
                    Assert.AreEqual(normal.X, Math.Cos(lat_rad) * Math.Cos(lon_rad), tolerance);
                    Assert.AreEqual(normal.Y, Math.Cos(lat_rad) * Math.Sin(lon_rad), tolerance);
                    Assert.AreEqual(normal.Z, Math.Sin(lat_rad), tolerance);
                    vContact.Normalize();
                    AssertVectorEqual(vContact, normal);
                }
            }
        }