I know, there are several questions to this topic, but I am just searching for the error in my own equations. I have no deeper geodetic background, but I am trying to understand these formulas instead just copy them.
So, I have a XYZ coordinate and want to get a geodetic coordinate. This is what I tried:
tan(longitude) = Y/X
For the latitude I tried this approach. On a sphere you could calculate it that way:
diameter_xy = sqrt(y^2 + x^2); // => d
tan(latitude) = z / d
Now, I have no sphere but an ellipsoid. So the latitude I already calculated is the same as the geocentric latitude of an ellipsoid, right? (let's call it p)
I tried to transform this into the geodetic latitude (q). The book "Geometric Geodesy I" from R. Rapp (p. 25, formula 3.62) creates this relation between geocentric and geodetic latitudes:
tan(p) = (1 - e^2) * tan(q)
So:
tan(q) = tan(p) / (1 - e^2)
= (z / d) / (1 - e^2) // taking the spherical formula above
= (z / sqrt(y^2 + x^2)) / (1 - e^2)
= z / ((1 - e^2) * sqrt(y^2 + x^2))
Well, now I don't come to an expected result. When I have a look a several solutions, the formula differs:
For example: https://gis.stackexchange.com/a/292635 The initial equation for the latitude seems to be the same as mine (beside the point, that atan2
is used instead of atan
, which is also not that clear to me). But later the height h becomes part of the equation. It absolutely not clear to my, why.
Well, I don't understand were is error and where do the real solutions (e.g. Ferrari or so) get that complicated.
Edit:
In my case the values result in a greater height. The XYZ point is not on the surface. But since I am not interested in the height above ground, but only in the angles, I thought, this wouldn't make any difference. Maybe I am wrong? Does my calculation only work for h == 0m
above ground? If so, how do I recognize the height and how do I eliminate this?
My use case is:
X = 7000000m
Y = 2000000m
Z = 10000000m
e = 0.00669438 // WGS84
So, I am getting:
lat: 53.95°
lon: 15.95°
The lat
real value is something like:
lat: 54.04° (h: 6,005 km)