Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Longitude, Latitude, Altitude to 3D-Cartesian Coordinate Systems

I'm wondering about the transformation from Lat,Lon,Alt Values to 3D-Systems like ECEF (Earth-Centered).

This can be implemented as follows (https://gist.github.com/1536054):

/*
 * WGS84 ellipsoid constants Radius
 */
private static final double a = 6378137;
/*
 * eccentricity
 */
private static final double e = 8.1819190842622e-2;

private static final double asq = Math.pow(a, 2);
private static final double esq = Math.pow(e, 2);

void convert(latitude,longitude,altitude){
   double lat = Math.toRadians(latitude);
   double lon = Math.toRadians(longitude);
   double alt = altitude;

   double N = a / Math.sqrt(1 - esq * Math.pow(Math.sin(lat), 2));

   x = (N + alt) * Math.cos(lat) * Math.cos(lon);
   y = (N + alt) * Math.cos(lat) * Math.sin(lon);
   z = ((1 - esq) * N + alt) * Math.sin(lat);
}

What in my opinion seems very strange is the fact, that a little change of the altitude, affects x,y and z, where I would expect, that it just affect one axis. For example, if I have two GPS-Points, which have same lat/lon values but different altitude values, I'll get 3 different x,y,z coordinates.

Can someone explain the "idea" behind this? This looks very curious to me... Is there any other 3D-System, in which only one of the values is changing, when I lower/higher my altitude value?

Thanks a lot!

like image 222
Frame91 Avatar asked Oct 22 '22 09:10

Frame91


1 Answers

If you look at this picture: ECEF Coordinate System

then you see why. ECEF is a cube arround the earth, centered in earth center. if altitude raises you move out. Lat/lon is an "angular" coordinate system where lat,lon are angles, ECEF is a cartesian coordinate system!

Probaly you thougt ECEF is like LatLon with center earth has altitude 0, but this is not the case.

like image 111
AlexWien Avatar answered Oct 25 '22 19:10

AlexWien