获取两个GPS点方位

2024-06-03 14:46:23 发布

您现在位置:Python中文网/ 问答频道 /正文

试图得到两个gps坐标方位角的度数,但得到了错误的结果。 我认为问题是python在radiant中的数学工作,但是当转换为学位时也得到了错误的结果。你知道吗

好的结果在30-33左右。 用这个代码,我得到0,75,当把rad转换成deg时,得到43。 这是我的密码:

import math

lat1 = 47.357818 
lon1 = 18.985417
lat2 = 47.369282 
lon2 = 18.996625
pi = 3.1415

X = math.cos(lat2) * math.sin(lon1-lon2)
Y = math.cos(lat1) * math.sin(lat2) - math.sin(lat1) * math.cos(lat2) * math.cos(lon2-lon1)
B = math.atan2(X,Y)

print B

请帮帮我,转换的好方法是什么? ps:对不起我的英语。你知道吗


Tags: 代码错误数学mathsincosgps度数