-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutil.py
More file actions
42 lines (35 loc) · 942 Bytes
/
util.py
File metadata and controls
42 lines (35 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# coding:utf-8
from math import atan
from math import fabs
from math import pow
from math import pi
from math import sqrt
def get_angle(t1, t2):
x1 = t1[0]
y1 = t1[1]
x2 = t2[0]
y2 = t2[1]
if (fabs(x1-x2) != 0):
atan_angle = atan(fabs(y2 - y1) / fabs(x2 - x1)) / pi * 180
else:
atan_angle = atan(fabs(y2 - y1) / 0.001) / pi * 180
if x1 <= x2 and y1 <= y2:
return atan_angle
if x1 <= x2 and y1 > y2:
return 360 - atan_angle
if x1 > x2 and y1 <= y2:
return 180 - atan_angle
if x1 > x2 and y1 > y2:
return 180 + atan_angle
def get_distance(t1, t2):
x1 = t1[0]
y1 = t1[1]
x2 = t2[0]
y2 = t2[1]
return sqrt(pow(x1-x2, 2) + pow(y1-y2, 2))
def is_shootable(t1, t2):
return 1
if __name__ == "__main__":
t1 = [13.491996547370965,1.9072850518774838]
t2 = [13.790854956798492,1.933431774701781]
print(get_distance(t1, t2))