12 lines
250 B
Python
12 lines
250 B
Python
|
import math
|
||
|
|
||
|
# DIRECTIONS GO BACKWARDS IN THIS GAME
|
||
|
# WHY NOT
|
||
|
def get_direction(x1,y1,x2,y2):
|
||
|
dx,dy=x2-x1,y2-y1
|
||
|
if dx==0: return math.pi*(2-sign(dy))/2
|
||
|
t=math.atan(dy/dx)
|
||
|
return t+math.pi*(sign(dx)<0)
|
||
|
|
||
|
def sign(num):
|
||
|
return (num>=0)*2-1-(num==0)
|