python实现已知两个点坐标求与正北夹角度数
2014-04-12 22:21
429 查看
代码如下:其中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
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语言已知三坐标求围成三角形的度数
- Python实现在matplotlib中两个坐标轴之间画一条直线光标的方法
- 使用python 在已知圆弧两个端点和中点坐标 计算圆弧的圆心坐标
- Python实现在matplotlib中两个坐标轴之间画一条直线光标的方法
- Python实现“已知三角形两个直角边,求斜边”
- leetcode 找到树中距离最大的两个结点,Python实现
- windows下python3.5安装setuptools以及百度坐标系(bd-09)、火星坐标系(国测局坐标系、gcj02)、WGS84坐标系之间的坐标互转python实现以及python中exce
- 在Python标准库的json包中,提供了JSONEncoder和JSONDecoder两个类来实现Json字符串和dict类型数据的互相转换。
- 实现 计算两个三维坐标点的 距离
- 用Python实现gmail邮箱服务,实现两个邮箱之间的绑定(中)
- 根据双眼的坐标对齐人脸Python实现
- 剑指offer:用两个栈实现队列(python)
- Python中实现两个字典(dict)合并的方法
- Windows下实现Python2和Python3两个版共存的方法
- 两个栈实现队列和两个队列实现栈-Python实现-复杂度分析
- Scrapy:Python实现scrapy框架爬虫两个网址下载网页内容信息——Jason niu
- 求两个数字的最大公约数-Python实现,三种方法效率比较,包含质数打印质数的方法
- Python实现将两个表格(txt格式)合并
- python实现两个线性表集合A和B的并集
- python实现合并两个数组的方法