Created
June 3, 2013 20:41
-
-
Save george-silva/5701220 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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