Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python获得两个GPS点方位_Python_Gps_Bearing - Fatal编程技术网

Python获得两个GPS点方位

Python获得两个GPS点方位,python,gps,bearing,Python,Gps,Bearing,尝试获取两个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(l

尝试获取两个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:对不起,我的英语不好。

你可能想看看。把你的纬度转换成弧度。然后把B从弧度转换成度,你会得到33.5分,愚蠢,忘了转换回来。谢谢但现在我得到了负的结果(-33.5091)