# Converting Longitude/Latitude/Altitude to Cartesian Coords

• 04-02-2008
Zeeshan
Converting Longitude/Latitude/Altitude to Cartesian Coords
Hi,

I want to convert Longitude/Latitude/Altitude coordinates of a point to x,y,z coordinates. Can anybody point to some mathematical formulae to do the same?

Actually, I have some 3D models in Google Earth's .KMZ format; all vertices stored in GE format are in Longitude/Lat./Alt. coordinate system, and I want them in cartesian coordinates.

Thanks a lot in advance.
• 04-02-2008
JacobN
I would go to this site on wikipedia that is about the spherical coordinate system, the equations for converting both ways should be right there. Just remember that those equations use radians as opposed to degrees.
• 04-11-2008
BobMcGee123
I think that you'd have to know a bit more about this particular type of format, as I don't know that just knowing the math for spherical coordinates would necessarily be enough (e.g. do they include the actual radius of the earth in the format? I doubt it) Understanding spherical coordinates is, however, the fundamental thing you'd need to know to solve this problem.

Let us know if you make any progress.
• 04-11-2008
Magos
• 04-12-2008
JacobN
Quote:

Originally Posted by BobMcGee123
I think that you'd have to know a bit more about this particular type of format, as I don't know that just knowing the math for spherical coordinates would necessarily be enough (e.g. do they include the actual radius of the earth in the format? I doubt it) Understanding spherical coordinates is, however, the fundamental thing you'd need to know to solve this problem.

Let us know if you make any progress.

Since he has the altitude, the longitude, the latitude and the radius, using the formulas on the site gives the following:

Code:

```x = (altitude+radius) * sin( longitude ) * cos( altitude ) y = (altitude+radius) * sin( longitude ) * sin( altitude ) z = (altitude+radius) * cos( longitude )```
So yeah, it does take the actual radius of the Earth into consideration... to some extend.
• 04-12-2008
VirtualAce
I'm sure longitude and lattitude must be in form 0 to PI and 0 to 2 * PI. That is the equation of a sphere.

x = sin(alpha) * cos(beta) * radius
y = sin(alpha) * sin(beta) * radius
z = cos(beta) * radius

alpha = 0 to 2 * PI
beta = 0 to PI

I'm fairly sure you cannot just plug in normal lattitude and longitude in that equation and arrive at a correct x,y,z.
• 04-24-2008
master5001
After reading this the first thing that came to my mind actually turned out to be the points brought up in the first thread where the user had posed this question. Not to revert back to what probably made you repost your question but wouldn't it first help to consider the fact you aren't mapping a sphere?