NAME
sphere2xy
FUNCTION
sphere2xy(r, x, y, z)
NOTES
Convert x, y, z on a sphere object with radius r to longitude and latitude in degree.
INPUTS
x, y, x - coordinate
OUTPUTS
longitude (0 to 360) and latitude (-90 to 90) in degree.
SOURCE
function sphere2xy(r, x, y, z)
local c = 57.29577951
lat = c * math.asin(z/r)
r = math.sqrt(x*x + y*y) + 1.e-15
lon = c * math.acos(x/r)
if y < 0 then lon = 360 - lon end
return lon, lat
end