Skip to content

Instantly share code, notes, and snippets.

@george-silva
Created June 3, 2013 20:41
Show Gist options
  • Select an option

  • Save george-silva/5701220 to your computer and use it in GitHub Desktop.

Select an option

Save george-silva/5701220 to your computer and use it in GitHub Desktop.
def azimute_reto(self,p1, p2, casas=3):
# guarda para nao entramos em loop infinito.
if casas > 15:
return None
delta_x = round(p2.x - p1.x, casas)
delta_y = round(p2.y - p1.y, casas)
if delta_x == 0 and delta_y == 0:
casas += 1
return self.azimute_reto(p1, p2, casas=casas)
if delta_x == 0 and delta_y > 0:
return 0
if delta_x > 0 and delta_y == 0:
return 90
if delta_x == 0 and delta_y < 0:
return 180
if delta_x < 0 and delta_y == 0:
return 270
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment