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); }
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); } }
public Float3(Float3 original) : this(original.AsVector3()) { }
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)); }