def contains_point(poly, point):
 n = len(poly)
 c = False
 i = 0
 j = (n - 1)
 while (i < n):
  if (((poly[i][0] > point[0]) != (poly[j][0] > point[0])) and (point[1] < ((((poly[j][1] - poly[i][1]) * (point[0] - poly[i][0])) / (poly[j][0] - poly[i][0])) + poly[i][1]))):
   c = (not c)
  j = i
  i += 1
 return c

def contains_point ( poly , point ) : n = len ( poly ) c = False i = 0 j = ( n - 1 ) while ( i < n ) : if ( ( ( poly [ i ] [ 0 ] > point [ 0 ] ) != ( poly [ j ] [ 0 ] > point [ 0 ] ) ) and ( point [ 1 ] < ( ( ( ( poly [ j ] [ 1 ] - poly [ i ] [ 1 ] ) * ( point [ 0 ] - poly [ i ] [ 0 ] ) ) / ( poly [ j ] [ 0 ] - poly [ i ] [ 0 ] ) ) + poly [ i ] [ 1 ] ) ) ) : c = ( not c ) j = i i += 1 return c
given a list of 2-tuples defining a convex polygon .