Converting Longitude/Latitude/Altitude to Cartesian Coords

This is a discussion on Converting Longitude/Latitude/Altitude to Cartesian Coords within the Game Programming forums, part of the General Programming Boards category; Hi, I want to convert Longitude/Latitude/Altitude coordinates of a point to x,y,z coordinates. Can anybody point to some mathematical formulae ...

  1. #1
    Registered User Zeeshan's Avatar
    Join Date
    Oct 2001
    Location
    Munich, Germany
    Posts
    224

    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.

  2. #2
    Registered User
    Join Date
    Nov 2007
    Posts
    46
    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.

  3. #3

    Join Date
    May 2005
    Posts
    1,041
    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.
    I'm not immature, I'm refined in the opposite direction.

  4. #4
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  5. #5
    Registered User
    Join Date
    Nov 2007
    Posts
    46
    Quote Originally Posted by BobMcGee123 View Post
    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.

  6. #6
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    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.

  7. #7
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    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?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting Longitude/Latitude/Altitude to Cartesian Coords
    By Zeeshan in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 04-07-2008, 03:01 PM
  2. Trying to convert vectors from cartesian coordinate
    By FALSTON01 in forum C++ Programming
    Replies: 1
    Last Post: 10-20-2005, 05:17 PM
  3. Heightfield Texture Coords
    By psychopath in forum Game Programming
    Replies: 1
    Last Post: 10-03-2005, 09:55 AM
  4. Converting from Screen to World Coordinates
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 05-11-2004, 12:51 PM
  5. Direct Input and Mouse Coords
    By Khelder in forum Game Programming
    Replies: 5
    Last Post: 12-30-2003, 01:29 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21