-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathactions.py
49 lines (44 loc) · 1.3 KB
/
actions.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
from directions import *
UP = NORTH
DOWN = SOUTH
LEFT = WEST
RIGHT = EAST
def RotateDirVec45Deg(dirVec,rotation):
if rotation == CW:
if dirVec == NORTH:
return NORTHEAST
elif dirVec == NORTHEAST:
return EAST
elif dirVec == EAST:
return SOUTHEAST
elif dirVec == SOUTHEAST:
return SOUTH
elif dirVec == SOUTH:
return SOUTHWEST
elif dirVec == SOUTHWEST:
return WEST
elif dirVec == WEST:
return NORTHWEST
elif dirVec == NORTHWEST:
return NORTH
elif rotation == CCW:
if dirVec == NORTH:
return NORTHWEST
elif dirVec == NORTHWEST:
return WEST
elif dirVec == WEST:
return SOUTHWEST
elif dirVec == SOUTHWEST:
return SOUTH
elif dirVec == SOUTH:
return SOUTHEAST
elif dirVec == SOUTHEAST:
return EAST
elif dirVec == EAST:
return NORTHEAST
elif dirVec == NORTHEAST:
return NORTH
def RotateDirVec90Deg(dirVec,rotation):
return RotateDirVec45Deg(RotateDirVec45Deg(dirVec,rotation),rotation)
def RotateDirVec180Deg(dirVec,rotation):
return RotateDirVec90Deg(RotateDirVec90Deg(dirVec,rotation),rotation)