Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 3
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);
                }
            }
        }