def left_on_right(v0, v1, x):
    """tests whether point x is left (output>0), on (=0), or right (<0)
    of the infinite line defined by v0, v1. x is many points as (N, 2) array"""
    return (v1[0] - v0[0])*(x[:,1] - v0[1]) - (x[:,0] - v0[0])*(v1[1] - v0[1])