首页 > 编程语言 > 详细

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

时间:2014-04-13 10:03:17      阅读:864      评论:0      收藏:0      [点我收藏+]

代码如下:其中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实现已知两个点坐标求与正北夹角度数

原文:http://blog.csdn.net/liuzhoulong/article/details/23559335

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!