Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import math
  2.  
  3. def klok(p):
  4. if len(p) <= 2:
  5. return 0
  6.  
  7. for ccw in [True, False]: #check voor wijzerszin en tegenwijzerszin
  8. follows_pattern = True
  9. prev_ang = math.atan2(p[0][1], p[0][0]) #atan geeft een hoek tussen -pi en pi
  10.  
  11. cross_pass = True
  12. for i in range(1,len(p)):
  13. ang = math.atan2(p[i][1], p[i][0])
  14. if (ccw and ang < prev_ang) or (not ccw and ang > prev_ang):
  15. if cross_pass: # de hoeken zullen eenmaal de scheiding passeren(1 toertje rond cirkel) deze cross_pas dient daarvoor. Als hij ervoor al wordt gebruikt, zal het bij de scheiding mislopen.
  16. cross_pass = False
  17. else:
  18. follows_patern = False
  19. break
  20.  
  21. prev_ang = ang
  22. if follows_pattern:
  23. return(1 if ccw else -1)
  24. return 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement