转换纬度和经度在三维空间中的点经度、纬度、空间

2023-09-08 00:20:57 作者:云自说

我需要的纬度和经度值转换为一个点,在3维空间。我一直在想这个约2小时了,但我没有得到正确的结果。

I need to convert latitude and longitude values to a point in the 3-dimensional space. I've been trying this for about 2 hours now, but I do not get the correct results.

在 Equirectangular 坐标来自 openflights.org 。我已经试过了的 COS 和的罪的几种组合,但结果却从不看像我们的小心爱的地球。

The Equirectangular coordinates come from openflights.org. I've tried several combinations of cos and sin, but the result did never look like our little beloved earth.

在下面,你可以看到应用转换维基百科暗示的结果。我认为,人们可以从上下文中猜出 c4d.Vector

In the following, you can see the result of applying the conversion Wikipedia suggests. I think one can guess from context what c4d.Vector is.

def llarToWorld(latit, longit, altid, rad):
    x = math.sin(longit) * math.cos(latit)
    z = math.sin(longit) * math.sin(latit)
    y = math.cos(longit)
    v = c4d.Vector(x, y, z)
    v = v * altid + v * rad
    return v

红色:X,绿色:Y,蓝:Z 的

一个确实能识别北部和南美洲,特别是在墨西哥湾的土地。然而,这看起来有点压扁和一种在错误的地方。

One can indeed identify North- and South America, especially the land around the Gulf of Mexico. However, it looks somewhat squished and kind of in the wrong place..

其结果是看起来有点旋转,我想,我想换经度和纬度。但是,结果是有点尴尬。

As the result looks somewhat rotated, I think, I tried swapping latitude and longitude. But that result is somewhat awkward.

def llarToWorld(latit, longit, altid, rad):
    temp = latit
    latit = longit
    longit = temp
    x = math.sin(longit) * math.cos(latit)
    z = math.sin(longit) * math.sin(latit)
    y = math.cos(longit)
    v = c4d.Vector(x, y, z)
    v = v * altid + v * rad
    return v

这是什么样的结果看起来不转换的值。

This is what the result looks like without converting the values.

def llarToWorld(latit, longit, altid, rad):
    return c4d.Vector(math.degrees(latit), math.degrees(longit), altid)

问题:我如何转换的经度和纬度正确

Question: How can I convert the longitude and latitude correctly?

由于TreyA,我发现上mathworks.com此页。在code,做它的工作是这样的:

Thanks to TreyA, I found this page on mathworks.com. The code that does it's work is the following:

def llarToWorld(lat, lon, alt, rad):
    # see: http://www.mathworks.de/help/toolbox/aeroblks/llatoecefposition.html
    f  = 0                              # flattening
    ls = atan((1 - f)**2 * tan(lat))    # lambda

    x = rad * cos(ls) * cos(lon) + alt * cos(lat) * cos(lon)
    y = rad * cos(ls) * sin(lon) + alt * cos(lat) * sin(lon)
    z = rad * sin(ls) + alt * sin(lat)

    return c4d.Vector(x, y, z)

其实,我换以Z ,因为地球是转动的话,但是,它的作品!这是结果:

Actually, I switched y and z because the earth was rotated then, however, it works! That's the result:

推荐答案

作为的 TreyA 的statet, LLA到ECEF 是解决方案。请参见 http://www.mathworks.de/help/tool​​box/aeroblks/llatoecefposition。 HTML

As TreyA statet, LLA to ECEF is the solution. See http://www.mathworks.de/help/toolbox/aeroblks/llatoecefposition.html