-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconversions.py
57 lines (44 loc) · 946 Bytes
/
conversions.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from constants import YARDS, METERS
def get_real_direction(direction, short=False):
if abs(direction)<22 or abs(direction-360)<22:
if short:
return 'e'
return 'east'
elif abs(direction-45)<22:
if short:
return 'ne'
return 'northeast'
elif abs(direction-90)<22:
if short:
return 'n'
return 'north'
elif abs(direction-135)<22:
if short:
return 'nw'
return 'northwest'
elif abs(direction-180)<22:
if short:
return 'w'
return 'west'
elif abs(direction-225)<22:
if short:
return 'sw'
return 'southwest'
elif abs(direction-270)<22:
if short:
return 's'
return 'south'
elif abs(direction-315)<22:
if short:
return 'se'
return 'southeast'
else:
if short:
return 'e'
return 'east'
def get_real_distance(distance, yards=True):
"""Returns the real-life representation of a distance."""
if yards:
return distance*YARDS
else:
return distance*METERS