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 ( int i = 0 , j ; i < n ; i ++ ) { j = ( i + 1 ) % n ; int x1 = a [ i ] . first , x2 = a [ j ] . first ; int y1 = a [ i ] . second , y2 = a [ j ] . second ; int a1 = y1 - y2 ; int b1 = x2 - x1 ; int c1 = x1 * y2 - y1 * x2 ; int for_mid = a1 * mid . first + b1 * mid . second + c1 ; int for_p = a1 * p . first + b1 * p . second + c1 ; if ( for_mid * for_p < 0 ) return false ; } return true ; }