将纬度和经度转换为 3D 空间中的点 [英] Convert Latitude and Longitude to point in 3D space

查看:35
本文介绍了将纬度和经度转换为 3D 空间中的点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将纬度和经度值转换为 3 维空间中的一个点.我已经尝试了大约 2 个小时,但我没有得到正确的结果.

Equirectangular 坐标来自 页面.完成它的工作的代码如下:

def llarToWorld(lat, lon, alt, rad):# 见:http://www.mathworks.de/help/toolbox/aeroblks/llatoecefposition.htmlf = 0 # 展平ls = atan((1 - f)**2 * tan(lat)) # lambdax = 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)返回 c4d.Vector(x, y, z)

实际上,我切换了yz 因为当时地球在旋转,但是,它有效!结果是这样的:

解决方案

作为 TreyA statet,LLA to ECEF 是解决方案.请参阅 http://www.mathworks.de/help/toolbox/aeroblks/llatoecefposition.html

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.

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.


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

Red: X, Green: Y, Blue: 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?


Solution

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)

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

解决方案

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

这篇关于将纬度和经度转换为 3D 空间中的点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆