if the mid and the given point lies always on the same side w . r . t every edge of the convex hull , then the point lies inside the convex hull
for i in range ( n ) : NEW_LINE INDENT j = ( i + 1 ) % n ; NEW_LINE x1 = a [ i ] [ 0 ] NEW_LINE x2 = a [ j ] [ 0 ] NEW_LINE y1 = a [ i ] [ 1 ] NEW_LINE y2 = a [ j ] [ 1 ] NEW_LINE a1 = y1 - y2 ; NEW_LINE b1 = x2 - x1 ; NEW_LINE c1 = x1 * y2 - y1 * x2 ; NEW_LINE for_mid = a1 * mid [ 0 ] + b1 * mid [ 1 ] + c1 ; NEW_LINE for_p = a1 * p [ 0 ] + b1 * p [ 1 ] + c1 ; NEW_LINE if ( for_mid * for_p < 0 ) : NEW_LINE INDENT return False ; NEW_LINE DEDENT DEDENT return True ; NEW_LINE