/// <summary> /// Returns three dimensional cartesian coordinates for this EarthCoordinate /// with vertical orientation to the center of the earth /// and horizontal orientation to the polar coordinates /// <remarks> /// X is meters -East/+West from the start /// Y is meters -South/+North from the start /// Z is meters -Below/+Above the start /// </remarks> /// </summary> /// <param name="start"></param> /// <returns></returns> public Point3 OffsetFromStart(EarthCoordinates start) { // Distance between start and end Longitude in meters. double y = 2.0 * Math.PI * ((((start._polarAxisMeters + this._polarAxisMeters) / 2.0)) / 360.0) * (start.Longitude - this.Longitude); // Difference in altitude double z = (this.AltitudeMeters - start.AltitudeMeters); // To calculate the difference in Latitude, // find the Longitude and Altitude midpoints double midLongitude = (start.Longitude + this.Longitude) / 2.0; double midAltitude = (start.AltitudeMeters + this.AltitudeMeters) / 2.0; EarthCoordinates lat1; if ((Math.Abs(midAltitude) > 20.0) || (Math.Abs(midLongitude) > 0.0001)) { // The points are spread apart, // so plot two new points at the starting and ending Latitude // and using the midpoints of Longitude and Altitude. lat1 = new EarthCoordinates(start.Latitude, midLongitude, midAltitude, start.DateTime, start.HorizontalDilutionOfPrecision, start.VerticalDilutionOfPrecision); } else { // The points are near the same Longitude and Altitude, // so calculate Latitude using the start Longitude and Altitude. lat1 = start; midLongitude = start.Longitude; midAltitude = start.AltitudeMeters; } EarthCoordinates lat2 = new EarthCoordinates(this.Latitude, midLongitude, midAltitude, this.DateTime, this.HorizontalDilutionOfPrecision, this.VerticalDilutionOfPrecision); // Finally, measure the distance between these points. double x = lat2.DistanceFromStart(lat1); return(new Point3(x, y, z)); }
/// <summary> /// Returns three dimensional cartesian coordinates for this EarthCoordinate /// with vertical orientation to the center of the earth /// and horizontal orientation to the polar coordinates /// <remarks> /// X is meters -East/+West from the start /// Y is meters -South/+North from the start /// Z is meters -Below/+Above the start /// </remarks> /// </summary> /// <param name="start"></param> /// <returns></returns> public Point3 OffsetFromStart(EarthCoordinates start) { // Distance between start and end Longitude in meters. double y = 2.0 * Math.PI * ((((start._polarAxisMeters + this._polarAxisMeters) / 2.0)) / 360.0) * (start.Longitude - this.Longitude); // Difference in altitude double z = (this.AltitudeMeters - start.AltitudeMeters); // To calculate the difference in Latitude, // find the Longitude and Altitude midpoints double midLongitude = (start.Longitude + this.Longitude) / 2.0; double midAltitude = (start.AltitudeMeters + this.AltitudeMeters) / 2.0; EarthCoordinates lat1; if ((Math.Abs(midAltitude) > 20.0) || (Math.Abs(midLongitude) > 0.0001)) { // The points are spread apart, // so plot two new points at the starting and ending Latitude // and using the midpoints of Longitude and Altitude. lat1 = new EarthCoordinates(start.Latitude, midLongitude, midAltitude, start.DateTime, start.HorizontalDilutionOfPrecision, start.VerticalDilutionOfPrecision); } else { // The points are near the same Longitude and Altitude, // so calculate Latitude using the start Longitude and Altitude. lat1 = start; midLongitude = start.Longitude; midAltitude = start.AltitudeMeters; } EarthCoordinates lat2 = new EarthCoordinates(this.Latitude, midLongitude, midAltitude, this.DateTime, this.HorizontalDilutionOfPrecision, this.VerticalDilutionOfPrecision); // Finally, measure the distance between these points. double x = lat2.DistanceFromStart(lat1); return new Point3(x, y, z); }