如何将2d网格点(x,y)映射到球体上作为3d点(x,y,z)

mil*_*lus 9 math 3d geometry map-projections

我有一组2d网格点(x,y),我想将其作为3d点(x,y,z)映射/投影到球体上.

我知道随着abs(y)的增加会对极点产生一些翘曲,但是我的网格补丁只能覆盖赤道附近的一部分球体,因此可以避免严重的翘曲.

我很难找到合适的方程式.

com*_*orm 19

从关于墨卡托投影的维基百科文章转述:

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
Run Code Online (Sandbox Code Playgroud)

要从逆映射的结果中获取3D坐标:

Given longitude and latitude on a sphere of radius S,
the 3D coordinates P = (P.x, P.y, P.z) are:
  P.x = S * cos(latitude) * cos(longitude)
  P.y = S * cos(latitude) * sin(longitude)
  P.z = S * sin(latitude)
Run Code Online (Sandbox Code Playgroud)

(请注意,"地图半径"和"3D半径"几乎肯定会有不同的值,所以我使用了不同的变量名.)