Example #1
0
 public static Float3 Average(Float3[] values)
 {
     if (values.Length == 0) return new Float3();
     Float3 sum = new Float3();
     foreach (Float3 val in values)
         sum = Float3.Add(sum, val);
     return new Float3(sum.X / values.Length, sum.Y / values.Length, sum.Z / values.Length);
 }
Example #2
0
 public Float3(Float3 original)
     : this(original.AsVector3())
 {
 }
Example #3
0
 public static Float3 UnwrapPhase(Float3 previous, Float3 current, double tolerance)
 {
     float x = UnwrapPhase(previous.X, current.X, tolerance);
     float y = UnwrapPhase(previous.Y, current.Y, tolerance);
     float z = UnwrapPhase(previous.Z, current.Z, tolerance);
     return new Float3(x, y, z);
 }
Example #4
0
 public static Float3[] UnwrapPhase(Float3[] values, float tolerance)
 {
     if (values.Length == 0) return values;
     Float3[] ret = new Float3[values.Length];
     ret[0] = values[0];
     for (int i = 1; i < values.Length; i++)
     {
         ret[i] = UnwrapPhase(ret[i - 1], values[i], tolerance);
     }
     return ret;
 }
 private void RestrictCameraElevation()
 {
     Float3 loc = new Float3(CameraLocation);
     if (loc.Y < -100)
     {
         loc.Y = -100;
         CameraLocation = loc;
     }
     if (loc.Y > (float)EarthTiles.MAX_ELEVATION)
     {
         loc.Y = (float)EarthTiles.MAX_ELEVATION;
         CameraLocation = loc;
     }
 }
Example #6
0
 public void CameraLocationChanged(Float3 newCameraLocation)
 {
     currentLocation = EarthProjection.ConvertCameraLocationToLatLong(newCameraLocation);
     currentElevation = EarthProjection.ConvertCameraLocationToElevation(newCameraLocation); ;
     MapPosition direction = CalculateTravelDirection(currentLocation, previousLocation,currentElevation,previousElevation);
     currentZoomLevel = EarthProjection.GetZoomFromElevation(currentElevation);
     if (direction != MapPosition.None && !FixTerrain)
     {
         MoveTerrainInDirection(direction, currentLocation, currentElevation);
     }
     UpdateAllTextures(currentElevation);
     previousLocation = currentLocation;
     previousElevation = currentElevation;
 }
 public static double ConvertCameraLocationToElevation(Float3 cameraLocation)
 {
     return cameraLocation.Y / UnitsPerMetreElevation;
 }
Example #8
0
 public static Float3 Subtract(Float3 a, Vector3 b)
 {
     return Subtract(a, new Float3(b));
 }
Example #9
0
 public static Float3 ConvertYawPitchRollToCartesian(Float3 yawPitchRoll)
 {
     return ConvertYawPitchRollToCartesian(yawPitchRoll.X, yawPitchRoll.Y, yawPitchRoll.Z);
 }
Example #10
0
 public static Float3 ConvertYawPitchRollToPolar(Float3 yawPitchRoll)
 {
     Float3 cart = ConvertYawPitchRollToCartesian(yawPitchRoll);
     return ConvertCartesianToPolar(cart);
 }
Example #11
0
 public static Float3 ConvertPolarToCartesian(Float3 polar)
 {
     double radius = polar.X;
     double azimuth = polar.Y;
     double elevation = polar.Z;
     double x = radius * Math.Sin(azimuth) * Math.Cos(elevation);
     double y = radius * Math.Sin(elevation);
     double z = radius * Math.Cos(azimuth) * Math.Cos(elevation);
     return new Float3(x, y, z);
 }
        private void UpdateMapTerrainThread(object o, DoWorkEventArgs e)
        {
            while (!terrainWorker.CancellationPending)
            {
                if (TerrainToProcess.Count > 0)
                {
                    try
                    {
                        MapDescriptor desc = TerrainToProcess.Peek();
                        Shape target = desc.Tag as CombinedMapData;
                        Shape shape = null;
                        shapeFactory.BottomLeftLatitude = desc.Latitude;
                        shapeFactory.BottomLeftLongitude = desc.Longitude;
                        shapeFactory.LatitudeDelta = desc.Delta;
                        shapeFactory.LongitudeDelta = desc.Delta;
                        if (!UseTerrainData)
                            shape = shapeFactory.GenerateNullShape();
                        else
                        {
                            shape = GenerateShapeFromFile(desc);
                        }
                        Float3 location = new Float3((float)(desc.Longitude * UnitsPerDegreeLatitude), 0, (float)(desc.Latitude * UnitsPerDegreeLatitude));
                        shape.Location = location.AsVector3();
                        target.CopyShapeFrom(shape);
                        FireMapUpdateCompletedEvent(new ShapeChangeEventArgs(target, ShapeChangeEventArgs.ChangeAction.Add));
                        TerrainToProcess.Dequeue();
                    }
                    catch (InvalidOperationException) { }
                }
                System.Threading.Thread.Sleep(10);

            }
        }
Example #13
0
 private void SetBroadLocation(Float3 value)
 {
     Vector3 broad = value.AsVector3();
     float dist = Vector3.Distance(broad, Location);
     mScale = new Vector3(mScale.X, dist, mScale.Z);
     Vector3 diff = Vector3.Subtract(broad, this.Location);
     double y = diff.Y;
     double x = diff.X;
     double z = diff.Z;
     Elevation = (float)(Math.Asin(y / dist));
     Azimuth = (float)(Math.Atan2(x, z));
 }
Example #14
0
 public static Float3 Add(Float3 a, Vector3 b)
 {
     return Add(a, new Float3(b));
 }
Example #15
0
 public static Float3 Subtract(Vector3 a, Float3 b)
 {
     return Subtract(new Float3(a), b);
 }
Example #16
0
 public static Float3 Add(Float3 a, Float3 b)
 {
     return new Float3(a.X + b.X, a.Y + b.Y, a.Z + b.Z);
 }
Example #17
0
 public static Float3 Subtract(Float3 a, Float3 b)
 {
     return new Float3(a.X - b.X, a.Y - b.Y, a.Z - b.Z);
 }
Example #18
0
 public static Float3 ConvertCartesianToPolar(Float3 cartesian)
 {
     Vector3 vec = cartesian.AsVector3();
     double radius = vec.Length();
     double azimuth = Math.Atan2(cartesian.X, cartesian.Z);
     if (azimuth < 0) azimuth += Math.PI * 2;
     double elevation = Math.Asin(cartesian.Y / radius);
     return new Float3(radius, azimuth, elevation);
 }
Example #19
0
 public static bool TryParse(string s, out Float3 result)
 {
     result = new Float3();
     string [] split = s.Split(new char[]{','},StringSplitOptions.RemoveEmptyEntries);
     if(split.Length != 3) return false;
     float f = 0;
     if(!float.TryParse(split[0],out f)) return false;
     result.X = f;
     if (!float.TryParse(split[1], out f)) return false;
     result.Y = f;
     if (!float.TryParse(split[2], out f)) return false;
     result.Z = f;
     return true;
 }
 public static LatLong ConvertCameraLocationToLatLong(Float3 cameraLocation)
 {
     float units = (float)UnitsPerDegreeLatitude;
     return new LatLong(cameraLocation.Z / units, cameraLocation.X / units);
 }
Example #21
0
 public static Float3[] UnwrapPhase(Float3[] values)
 {
     return UnwrapPhase(values, (float)Math.PI);
 }
Example #22
0
 public void InitializeAtCameraLocation(Float3 cameraLocation)
 {
     LatLong latLong = EarthProjection.ConvertCameraLocationToLatLong(cameraLocation);
     double elevation = EarthProjection.ConvertCameraLocationToElevation(cameraLocation);
     InitializeAtGivenLatLongElevation(latLong, elevation);
 }
 private void engine_CameraChanged(object sender, EventArgs e)
 {
     if (this.isInitialized)
     {
         RestrictCameraElevation();
         if (previousCameraLocation.X != CameraLocation.X || previousCameraLocation.Z != CameraLocation.Z || previousCameraLocation.Y != CameraLocation.Y)
         {
             earthTiles.CameraLocationChanged(new Float3(CameraLocation));
         }
         UpdateDebugString();
     }
     previousCameraLocation = new Float3(CameraLocation);
 }