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