Paraphrased from a Wikipedia article on Mercator projection:
Given a "mapping sphere" of radius R, the Mercator projection (x,y) of a given latitude and longitude is: x = R * longitude y = R * log( tan( (latitude + pi/2)/2 ) ) and the inverse mapping of a given map location (x,y) is: longitude = x / R latitude = 2 * atan(exp(y/R)) - pi/2
To get 3D coordinates from the inverse mapping result:
Given longitude and latitude on a sphere of radius S, the 3D coordinates P = (Px, Py, Pz) are: Px = S * cos(latitude) * cos(longitude) Py = S * cos(latitude) * sin(longitude) Pz = S * sin(latitude)
(Note that “map radius” and “three-dimensional radius” will almost certainly have different meanings, so I used different variable names.)
comingstorm
source share