python实现已知两个点坐标求与正北夹角度数

代码如下:其中s(x_point_s,y_point_s),e(x_point_e,y_point_e)为两点坐标:

def calc_angle(x_point_s,y_point_s,x_point_e,y_point_e):
    angle=0
    y_se= y_point_e-y_point_s;
    x_se= x_point_e-x_point_s;
    if x_se==0 and y_se>0:
        angle = 360
    if x_se==0 and y_se<0:
        angle = 180
    if y_se==0 and x_se>0:
        angle = 90
    if y_se==0 and x_se<0:
        angle = 270
    if x_se>0 and y_se>0:
       angle = math.atan(x_se/y_se)*180/math.pi
    elif x_se<0 and y_se>0:
       angle = 360 + math.atan(x_se/y_se)*180/math.pi
    elif x_se<0 and y_se<0:
       angle = 180 + math.atan(x_se/y_se)*180/math.pi
    elif x_se>0 and y_se<0:
       angle = 180 + math.atan(x_se/y_se)*180/math.pi
    return angle
  

python实现已知两个点坐标求与正北夹角度数,布布扣,bubuko.com

python实现已知两个点坐标求与正北夹角度数

上一篇:2021-4-12 日报博客


下一篇:IOC原理