def is_left(p, p1, p2):
    """
    Tests if point p is to the left of a line segement
    between p1 and p2
    Output
       0  the point is on the line
      >0  p is to the left of the line
      <0  p is to the right of the line
    """
    return (p2.x-p1.x)*(p.y-p1.y) - (p.x-p1.x)*(p2.y-p1.y)