/// <summary> /// Converts DIS xyz world coordinates to latitude and longitude (IN DEGREES). This algorithm may not be 100% accurate /// near the poles. Uses WGS84 , though you can change the ellipsoid constants a and b if you want to use something /// else. These formulas were obtained from Military Handbook 600008 </summary> /// <param name="xyz"> A double array with the x, y, and z coordinates, in that order. </param> /// <returns> An array with the lat, lon, and elevation corresponding to those coordinates. /// Elevation is in meters, lat and long are in degrees </returns> public static double[] xyzToLatLonDegrees(double[] xyz) { double[] degrees = CoordinateConversions.xyzToLatLonRadians(xyz); degrees[0] = degrees[0] * 180.0 / Math.PI; degrees[1] = degrees[1] * 180.0 / Math.PI; return(degrees); }
/// <summary> /// Converts lat long IN DEGREES and geodetic height (elevation) into DIS XYZ /// This algorithm also uses the WGS84 ellipsoid, though you can change the values /// of a and b for a different ellipsoid. Adapted from Military Handbook 600008 </summary> /// <param name="latitude"> The latitude, IN DEGREES </param> /// <param name="longitude"> The longitude, in DEGREES </param> /// <param name="height"> The elevation, in meters </param> /// <returns> a double array with the calculated X, Y, and Z values, in that order </returns> public static double[] getXYZfromLatLonDegrees(double latitude, double longitude, double height) { double[] degrees = CoordinateConversions.getXYZfromLatLonRadians(latitude * CoordinateConversions.DEGREES_TO_RADIANS, longitude * CoordinateConversions.DEGREES_TO_RADIANS, height); return(degrees); }