public static Position fromECEF (double x, double y, double z) {

		double p = sqrt(x*x + y*y);
		double th = atan2(a * z, b * p);
		double lon = atan2(y, x);
		double lat = atan2(
				(z + (a*a - b*b) / (b*b) * b * pow(sin(th), 3)),
				p - e2 * a * pow(cos(th), 3));
		double N = a / sqrt(1 - pow(sqrt(e2) * sin(lat), 2));
		double alt = p / cos(lat) - N;

		// correct for numerical instability in altitude near exact poles:
		// after this correction, error is about 2 millimeters, which is about
		// the same as the numerical precision of the overall function
		if (abs(x) < 1 & abs(y) < 1)
			alt = abs(z) - b;

		return new Position(toDegrees(lon), toDegrees(lat), tools.meters2Feet(alt));
	}
public static Position fromECEF ( double x , double y , double z ) { double p = sqrt ( x * x + y * y ) ; double th = atan2 ( a * z , b * p ) ; double lon = atan2 ( y , x ) ; double lat = atan2 ( ( z + ( a * a - b * b ) / ( b * b ) * b * pow ( sin ( th ) , 3 ) ) , p - e2 * a * pow ( cos ( th ) , 3 ) ) ; double N = a / sqrt ( 1 - pow ( sqrt ( e2 ) * sin ( lat ) , 2 ) ) ; double alt = p / cos ( lat ) - N ; if ( abs ( x ) < 1 & abs ( y ) < 1 ) alt = abs ( z ) - b ; return new Position ( toDegrees ( lon ) , toDegrees ( lat ) , tools . meters2Feet ( alt ) ) ; }
Converts a cartesian earth-centered earth-fixed coordinate into an WGS84 LLA position
@param x coordinate in meters
@param y coordinate in meters
@param z coordinate in meters
@return a position object representing the WGS84 position