daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Jan 24th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top