math.atan2的说明图示

math.atan2的图形:
math.atan2的说明图示_第1张图片
以x轴正向为起点,x正向范围[0,180]。

math.atan2代码:

import math

x1, y1 = 0,0
x2, y2 = 0,2
temp = math.atan2((y2 - y1), (x2 - x1))
angle = temp / math.pi * 180
print(angle)

x1, y1 = 0,0
x2, y2 = 2,2
temp = math.atan2((y2 - y1), (x2 - x1))
angle = temp / math.pi * 180
print(angle)

x1, y1 = 0,0
x2, y2 = 2,0
temp = math.atan2((y2 - y1), (x2 - x1))
angle = temp / math.pi * 180
print(angle)

x1, y1 = 0,0
x2, y2 = 2,-2
temp = math.atan2((y2 - y1), (x2 - x1))
angle = temp / math.pi * 180
print(angle)

x1, y1 = 0,0
x2, y2 = 0,-2
temp = math.atan2((y2 - y1), (x2 - x1))
angle = temp / math.pi * 180
print(angle)

x1, y1 = 0,0
x2, y2 = -2,-2
temp = math.atan2((y2 - y1), (x2 - x1))
angle = temp / math.pi * 180
print(angle)

x1, y1 = 0,0
x2, y2 = -2,0
temp = math.atan2((y2 - y1), (x2 - x1))
angle = temp / math.pi * 180
print(angle)

x1, y1 = 0,0
x2, y2 = -2,2
temp = math.atan2((y2 - y1), (x2 - x1))
angle = temp / math.pi * 180
print(angle)

math.atan2的说明图示_第2张图片

你可能感兴趣的:(几何算法,python)