Advertisement
Guest User

Untitled

a guest
Jan 24th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. n = int(input())
  2. xp = []
  3. yp = []
  4. for i in range(n):
  5. s = [int(x) for x in input().split()]
  6. xp.append(s[0])
  7. yp.append(s[1])
  8. x, y =[float(s) for s in input().split()]
  9. def inPolygon(x, y, xp, yp):
  10. c = 0
  11. for i in range(n):
  12. if (((yp[i] <= y and y < yp[i - 1]) or (yp[i - 1] <= y and y < yp[i])) and (x > (xp[i - 1] - xp[i]) * (y - yp[i]) / (yp[i - 1] - yp[i]) + xp[i])):
  13. c = 1 - c
  14. return c
  15. a =inPolygon(x,y,xp,yp)
  16. if a == 1:
  17. print('YES')
  18. else:
  19. print('NO')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement