- Home /
Convert Geolocation to 3d position
Hello:
I have a globe mesh model like the one seen in google earth. I wonder if there is a common way, like formula or api for unity, to convert the geolocation (altitude, longitude) to be located for the globe model.
Thanks for any suggestions and guidelines.
Answer by DaveA · Apr 29, 2011 at 06:27 PM
Do you mean spherical coordinates, like for a simple sphere (http://en.wikipedia.org/wiki/Spherical_coordinate_system), or real-live coordinates? Real-live coordinates can get pretty involved depending on how detailed you need to get. Look into Mercator projection, UTM (http://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system) etc.
The simplest form is
x = r * sin (lat) * cos (lon)
y = r * sin (lat) * sin (lon)
z = r * cos (lat)
where r is radius (altitude = r + height_above_r) lon is longitude lat is latitude
This may all be off by 90 degrees depending on your orientation
Thanks for the useful information. One question: will the rotation be considered? The object down will always be point to the center of the sphere, similar to the effect you see in $$anonymous$$ario Galaxy