Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def klok(p):
- if len(p) <= 2:
- return 0
- for ccw in [True, False]: #check voor wijzerszin en tegenwijzerszin
- follows_pattern = True
- prev_ang = math.atan2(p[0][1], p[0][0]) #atan geeft een hoek tussen -pi en pi
- cross_pass = True
- for i in range(1,len(p)):
- ang = math.atan2(p[i][1], p[i][0])
- if (ccw and ang < prev_ang) or (not ccw and ang > prev_ang):
- 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.
- cross_pass = False
- else:
- follows_patern = False
- break
- prev_ang = ang
- if follows_pattern:
- return(1 if ccw else -1)
- return 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement