【问题标题】:how map 2d grid points (x,y) onto sphere as 3d points (x,y,z)如何将 2d 网格点 (x,y) 作为 3d 点 (x,y,z) 映射到球体上
【发布时间】:2012-10-04 17:31:22
【问题描述】:

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

我意识到随着 abs(y) 的增加,两极会有一些翘曲,但我的网格补丁只会覆盖赤道附近球体的一部分,因此可以避免严重的翘曲。

我很难找到正确的方程式。

【问题讨论】:

  • 我不知道你在这里问什么...2D xy 代表什么?它们是纬度/经度,还是球体平面矩形投影上的坐标?在最后一种情况下,您使用的是什么投影?

标签: math 3d geometry map-projections


【解决方案1】:

引用自维基百科关于墨卡托投影的文章:

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 坐标:

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半径”几乎肯定会有不同的值,所以我使用了不同的变量名。)

【讨论】:

  • 我的纬度是 29.65163。当我尝试计算 y 值时,我收到一个错误(在 Python 中),因为 tan((latitude + pi/2)/2) 是 -0.0970531183,并且对该值执行日志会引发“数学域错误”,因为该值为负数。我做错了什么?
  • 在添加pi/2 之前,您需要将纬度从度数转换为弧度数。这会将+/- 90 degrees 的范围转换为+/- pi/2 radians 的范围,除非您在两极,否则不会溢出函数范围(在这种情况下,墨卡托投影无论如何都是单数...)
  • 你知道如何从x、y、z得到经纬度吗?
  • 纬度是atan2(z, sqrt(x*x+y*y)),经度是atan2(y,x)。这两个都产生弧度,可以直接在逆映射中使用,但如果你想要的话,必须将其转换为度数。
【解决方案2】:

我想你在球体上的 (x,y) 是纬度,经度。

如果是这样,请参阅http://tutorial.math.lamar.edu/Classes/CalcII/SphericalCoords.aspx

那里:

phi = 90 度 - 纬度

theta = 经度

rho = 球体半径。

【讨论】:

    【解决方案3】:

    我希望您可以使用任意多个地球投影的倒数。

    与其他投影相比,墨卡托在赤道附近的表现相当不错。

    公式在 wiki 页面上。
    http://en.wikipedia.org/wiki/Mercator_projection

    【讨论】:

    • 谢谢。我意识到这就是我想要的,但是我在推导将球体上的 2d 点 (x,y) 到 3d 点 (x,y,z) 的方程时遇到了麻烦。
    • 啊,实际的公式。这是一个重要的数学运算,您可能在math.stackexchange.com 上运气更好。获得公式后,您可以返回此处寻求编程帮助。另外,wiki.openstreetmap.org/wiki/Mercator
    猜你喜欢
    • 1970-01-01
    • 2022-12-10
    • 1970-01-01
    • 2011-06-12
    • 2014-07-21
    • 1970-01-01
    • 2012-09-30
    • 1970-01-01
    • 2016-11-02
    相关资源
    最近更新 更多