Esempio n. 1
0
 public void Construct()
 {
     Geodetic3D a = new Geodetic3D(1.0, 2.0, 3.0);
     Assert.AreEqual(1.0, a.Longitude);
     Assert.AreEqual(2.0, a.Latitude);
     Assert.AreEqual(3.0, a.Height);
 }
Esempio n. 2
0
        public Vector3D GeodeticSurfaceNormal(Geodetic3D geodetic)
        {
            double cosLatitude = Math.Cos(geodetic.Latitude);

            return new Vector3D(
                cosLatitude * Math.Cos(geodetic.Longitude),
                cosLatitude * Math.Sin(geodetic.Longitude),
                Math.Sin(geodetic.Latitude));
        }
Esempio n. 3
0
        public void TestEquals()
        {
            Geodetic3D a = new Geodetic3D(1.0, 2.0, 3.0);
            Geodetic3D b = new Geodetic3D(1.0, 2.0, 4.0);
            Geodetic3D c = new Geodetic3D(1.0, 3.0, 3.0);
            Geodetic3D d = new Geodetic3D(2.0, 2.0, 3.0);
            Geodetic3D e = new Geodetic3D(1.0, 2.0, 3.0);

            object objA = a;
            object objB = b;
            object objC = c;
            object objD = d;
            object objE = e;

            Assert.IsTrue(a.Equals(a));
            Assert.IsTrue(a.Equals(e));
            Assert.IsTrue(e.Equals(a));
            Assert.IsTrue(a.Equals(objA));
            Assert.IsTrue(a.Equals(objE));
            Assert.IsTrue(objA.Equals(objA));
            Assert.IsTrue(objA.Equals(objE));

            Assert.IsTrue(a == e);
            Assert.IsTrue(e == a);
            Assert.IsTrue(a != b);
            Assert.IsTrue(a != c);
            Assert.IsTrue(a != d);

            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(a.Equals(c));
            Assert.IsFalse(a.Equals(d));

            Assert.IsFalse(b.Equals(a));
            Assert.IsFalse(c.Equals(a));
            Assert.IsFalse(d.Equals(a));

            Assert.IsFalse(a.Equals(objB));
            Assert.IsFalse(a.Equals(objC));
            Assert.IsFalse(a.Equals(objD));

            Assert.IsFalse(objA.Equals(objB));
            Assert.IsFalse(objA.Equals(objC));
            Assert.IsFalse(objA.Equals(objD));

            Assert.IsFalse(a == b);
            Assert.IsFalse(a == c);
            Assert.IsFalse(a == d);
            Assert.IsFalse(a != e);

            Assert.IsFalse(a.Equals(null));
            Assert.IsFalse(a.Equals(5));
        }
Esempio n. 4
0
        public void TestGetHashCode()
        {
            Geodetic3D a = new Geodetic3D(1.0, 2.0, 3.0);
            Geodetic3D b = new Geodetic3D(1.0, 2.0, 4.0);
            Geodetic3D c = new Geodetic3D(1.0, 3.0, 3.0);
            Geodetic3D d = new Geodetic3D(2.0, 2.0, 3.0);
            Geodetic3D e = new Geodetic3D(1.0, 2.0, 3.0);

            Assert.AreEqual(a.GetHashCode(), e.GetHashCode());
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
            Assert.AreNotEqual(a.GetHashCode(), c.GetHashCode());
            Assert.AreNotEqual(a.GetHashCode(), d.GetHashCode());
        }
Esempio n. 5
0
        /// <summary>
        /// Sets the <see cref="CenterPoint"/> and <see cref="FixedToLocalRotation"/> properties so that the
        /// camera is looking at a given longitude, latitude, and height and is oriented in that point's local
        /// East-North-Up frame.  This method does not change the <see cref="Azimuth"/>, <see cref="Elevation"/>,
        /// or <see cref="Range"/> properties, but the existing values of those properties are interpreted in the
        /// new reference frame.
        /// </summary>
        /// <param name="longitude">The longitude of the point to look at, in radians.</param>
        /// <param name="latitude">The latitude of the point to look at, in radians.</param>
        /// <param name="height">The height of the point to look at, in meters above the <see cref="Ellipsoid"/> surface.</param>
        public void ViewPoint(Ellipsoid ellipsoid, Geodetic3D geographic)
        {
            _centerPoint = ellipsoid.ToVector3D(geographic);

            // Fixed to East-North-Up rotation, from Wikipedia's "Geodetic System" topic.
            double cosLon = Math.Cos(geographic.Longitude);
            double cosLat = Math.Cos(geographic.Latitude);
            double sinLon = Math.Sin(geographic.Longitude);
            double sinLat = Math.Sin(geographic.Latitude);

            _fixedToLocalRotation =
                new Matrix3D(-sinLon, cosLon, 0.0,
                             -sinLat * cosLon, -sinLat * sinLon, cosLat,
                             cosLat * cosLon, cosLat * sinLon, sinLat);

            UpdateCameraFromParameters();
        }
Esempio n. 6
0
        /// <summary>
        /// Sets the <see cref="CenterPoint"/> and <see cref="FixedToLocalRotation"/> properties so that the
        /// camera is looking at a given longitude, latitude, and height and is oriented in that point's local
        /// East-North-Up frame.  This method does not change the <see cref="Azimuth"/>, <see cref="Elevation"/>,
        /// or <see cref="Range"/> properties, but the existing values of those properties are interpreted in the
        /// new reference frame.
        /// </summary>
        /// <param name="longitude">The longitude of the point to look at, in radians.</param>
        /// <param name="latitude">The latitude of the point to look at, in radians.</param>
        /// <param name="height">The height of the point to look at, in meters above the <see cref="Ellipsoid"/> surface.</param>
        public void ViewPoint(Ellipsoid ellipsoid, Geodetic3D geographic)
        {
            _centerPoint = ellipsoid.ToVector3D(geographic);
            
            // Fixed to East-North-Up rotation, from Wikipedia's "Geodetic System" topic.
            double cosLon = Math.Cos(geographic.Longitude);
            double cosLat = Math.Cos(geographic.Latitude);
            double sinLon = Math.Sin(geographic.Longitude);
            double sinLat = Math.Sin(geographic.Latitude);
            _fixedToLocalRotation =
                new Matrix3D(-sinLon,            cosLon,             0.0,
                             -sinLat * cosLon,   -sinLat * sinLon,   cosLat,
                             cosLat * cosLon,    cosLat * sinLon,    sinLat);

            UpdateCameraFromParameters();
        }
Esempio n. 7
0
        public Vector3D ToVector3D(Geodetic3D geodetic)
        {
            Vector3D n = GeodeticSurfaceNormal(geodetic);
            Vector3D k = _radiiSquared.MultiplyComponents(n);
            double gamma = Math.Sqrt(
                (k.X * n.X) +
                (k.Y * n.Y) +
                (k.Z * n.Z));

            Vector3D rSurface = k / gamma;
            return rSurface + (geodetic.Height * n);
        }
 private void OnKeyDown(object sender, KeyboardKeyEventArgs e)
 {
     if (e.Key == KeyboardKey.U)
     {
         _sceneState.SunPosition = _sceneState.Camera.Eye;
     }
     else if (e.Key == KeyboardKey.W)
     {
         _clipmap.Wireframe = !_clipmap.Wireframe;
         UpdateHUD();
     }
     else if (e.Key == KeyboardKey.B)
     {
         if (!_clipmap.BlendRegionsEnabled)
         {
             _clipmap.BlendRegionsEnabled = true;
             _clipmap.ShowBlendRegions    = false;
         }
         else if (_clipmap.ShowBlendRegions)
         {
             _clipmap.BlendRegionsEnabled = false;
         }
         else
         {
             _clipmap.ShowBlendRegions = true;
         }
         UpdateHUD();
     }
     else if (e.Key == KeyboardKey.L)
     {
         _clipmap.LodUpdateEnabled = !_clipmap.LodUpdateEnabled;
         UpdateHUD();
     }
     else if (e.Key == KeyboardKey.C)
     {
         _clipmap.ColorClipmapLevels = !_clipmap.ColorClipmapLevels;
         if (_clipmap.ColorClipmapLevels)
         {
             _clipmap.ShowImagery = false;
             _clipmap.Lighting    = true;
         }
         UpdateHUD();
     }
     else if (e.Key == KeyboardKey.I)
     {
         _clipmap.ShowImagery = !_clipmap.ShowImagery;
         _clipmap.Lighting    = !_clipmap.ShowImagery;
         if (_clipmap.ShowImagery)
         {
             _clipmap.ColorClipmapLevels = false;
         }
         UpdateHUD();
     }
     else if (e.Key == KeyboardKey.S)
     {
         _clipmap.Lighting = !_clipmap.Lighting;
         UpdateHUD();
     }
     else if (e.Key == KeyboardKey.Z)
     {
         if (_lookCamera != null)
         {
             double     longitude = -119.5326056;
             double     latitude  = 37.74451389;
             Geodetic3D halfDome  = new Geodetic3D(Trig.ToRadians(longitude), Trig.ToRadians(latitude), 2700.0);
             _lookCamera.ViewPoint(_ellipsoid, halfDome);
             _lookCamera.Azimuth   = 0.0;
             _lookCamera.Elevation = Trig.ToRadians(30.0);
             _lookCamera.Range     = 10000.0;
         }
     }
     else if (e.Key == KeyboardKey.F)
     {
         if (_lookCamera != null)
         {
             _lookCamera.Dispose();
             _lookCamera             = null;
             _flyCamera              = new CameraFly(_sceneState.Camera, _window);
             _flyCamera.MovementRate = 1200.0;
         }
         else if (_flyCamera != null)
         {
             _flyCamera.Dispose();
             _flyCamera = null;
             _sceneState.Camera.Target = new Vector3D(0.0, 0.0, 0.0);
             _lookCamera = new CameraLookAtPoint(_sceneState.Camera, _window, _ellipsoid);
             _lookCamera.UpdateParametersFromCamera();
         }
         UpdateHUD();
     }
     else if (_flyCamera != null && (e.Key == KeyboardKey.Plus || e.Key == KeyboardKey.KeypadPlus))
     {
         _flyCamera.MovementRate *= 2.0;
         UpdateHUD();
     }
     else if (_flyCamera != null && (e.Key == KeyboardKey.Minus || e.Key == KeyboardKey.KeypadMinus))
     {
         _flyCamera.MovementRate *= 0.5;
         UpdateHUD();
     }
     else if (e.Key == KeyboardKey.E)
     {
         if (_clipmap.Ellipsoid.MaximumRadius == _clipmap.Ellipsoid.MinimumRadius)
         {
             _clipmap.Ellipsoid = Ellipsoid.Wgs84;
             _globe.Shape       = Ellipsoid.Wgs84;
         }
         else
         {
             double radius = Ellipsoid.Wgs84.MaximumRadius;
             _clipmap.Ellipsoid = new Ellipsoid(radius, radius, radius);
             _globe.Shape       = _clipmap.Ellipsoid;
         }
     }
 }
Esempio n. 9
0
 public static Geodetic3D ToDegrees(Geodetic3D geodetic)
 {
     return new Geodetic3D(ToDegrees(geodetic.Longitude), ToDegrees(geodetic.Latitude), geodetic.Height);
 }
 private void OnKeyDown(object sender, KeyboardKeyEventArgs e)
 {
     if (e.Key == KeyboardKey.U)
     {
         _sceneState.SunPosition = _sceneState.Camera.Eye;
     }
     else if (e.Key == KeyboardKey.W)
     {
         _clipmap.Wireframe = !_clipmap.Wireframe;
         UpdateHUD();
     }
     else if (e.Key == KeyboardKey.B)
     {
         if (!_clipmap.BlendRegionsEnabled)
         {
             _clipmap.BlendRegionsEnabled = true;
             _clipmap.ShowBlendRegions = false;
         }
         else if (_clipmap.ShowBlendRegions)
         {
             _clipmap.BlendRegionsEnabled = false;
         }
         else
         {
             _clipmap.ShowBlendRegions = true;
         }
         UpdateHUD();
     }
     else if (e.Key == KeyboardKey.L)
     {
         _clipmap.LodUpdateEnabled = !_clipmap.LodUpdateEnabled;
         UpdateHUD();
     }
     else if (e.Key == KeyboardKey.C)
     {
         _clipmap.ColorClipmapLevels = !_clipmap.ColorClipmapLevels;
         if (_clipmap.ColorClipmapLevels)
         {
             _clipmap.ShowImagery = false;
             _clipmap.Lighting = true;
         }
         UpdateHUD();
     }
     else if (e.Key == KeyboardKey.I)
     {
         _clipmap.ShowImagery = !_clipmap.ShowImagery;
         _clipmap.Lighting = !_clipmap.ShowImagery;
         if (_clipmap.ShowImagery)
         {
             _clipmap.ColorClipmapLevels = false;
         }
         UpdateHUD();
     }
     else if (e.Key == KeyboardKey.S)
     {
         _clipmap.Lighting = !_clipmap.Lighting;
         UpdateHUD();
     }
     else if (e.Key == KeyboardKey.Z)
     {
         if (_lookCamera != null)
         {
             double longitude = -119.5326056;
             double latitude = 37.74451389;
             Geodetic3D halfDome = new Geodetic3D(Trig.ToRadians(longitude), Trig.ToRadians(latitude), 2700.0);
             _lookCamera.ViewPoint(_ellipsoid, halfDome);
             _lookCamera.Azimuth = 0.0;
             _lookCamera.Elevation = Trig.ToRadians(30.0);
             _lookCamera.Range = 10000.0;
         }
     }
     else if (e.Key == KeyboardKey.F)
     {
         if (_lookCamera != null)
         {
             _lookCamera.Dispose();
             _lookCamera = null;
             _flyCamera = new CameraFly(_sceneState.Camera, _window);
             _flyCamera.MovementRate = 1200.0;
         }
         else if (_flyCamera != null)
         {
             _flyCamera.Dispose();
             _flyCamera = null;
             _sceneState.Camera.Target = new Vector3D(0.0, 0.0, 0.0);
             _lookCamera = new CameraLookAtPoint(_sceneState.Camera, _window, _ellipsoid);
             _lookCamera.UpdateParametersFromCamera();
         }
         UpdateHUD();
     }
     else if (_flyCamera != null && (e.Key == KeyboardKey.Plus || e.Key == KeyboardKey.KeypadPlus))
     {
         _flyCamera.MovementRate *= 2.0;
         UpdateHUD();
     }
     else if (_flyCamera != null && (e.Key == KeyboardKey.Minus || e.Key == KeyboardKey.KeypadMinus))
     {
         _flyCamera.MovementRate *= 0.5;
         UpdateHUD();
     }
     else if (e.Key == KeyboardKey.E)
     {
         if (_clipmap.Ellipsoid.MaximumRadius == _clipmap.Ellipsoid.MinimumRadius)
         {
             _clipmap.Ellipsoid = Ellipsoid.Wgs84;
             _globe.Shape = Ellipsoid.Wgs84;
         }
         else
         {
             double radius = Ellipsoid.Wgs84.MaximumRadius;
             _clipmap.Ellipsoid = new Ellipsoid(radius, radius, radius);
             _globe.Shape = _clipmap.Ellipsoid;
         }
     }
 }