如何将 2d 网格点 (x,y) 作为 3d 点 (x,y,z) 映射到球体上 [英] how map 2d grid points (x,y) onto sphere as 3d points (x,y,z)
问题描述
我有一组 2d 网格点 (x,y),我想将它们作为 3d 点 (x,y,z) 映射/投影到球体上.
I have a set of 2d grid points (x,y) that I want to map/project onto a sphere as 3d points (x,y,z).
我意识到随着 abs(y) 的增加会向两极发生一些翘曲,但我的网格补丁只会覆盖赤道附近的一部分球体,因此可以避免严重的翘曲.
I realize there will be some warping towards the poles as abs(y) increases but my grid patch will only cover a portion of the sphere near the equator so severe warping will be avoided.
我找不到合适的方程式.
I'm having trouble finding the right equations for that.
推荐答案
转述自维基百科关于墨卡托投影的文章:
Paraphrased from the 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
从逆映射的结果中获取 3D 坐标:
To get the 3D coordinates from the result of the inverse mapping:
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)
(注意地图半径"和3D半径"几乎肯定会有不同的值,所以我使用了不同的变量名.)
(Note that the "map radius" and the "3D radius" will almost certainly have different values, so I have used different variable names.)
这篇关于如何将 2d 网格点 (x,y) 作为 3d 点 (x,y,z) 映射到球体上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!