def side_of_line(l, p):
    """Returns on which side of line `l` point `p` lies.

    Line `l` must be a tuple of two tuples, which are the start and end
    point of the line. Point `p` is a single tuple.

    Returned value is negative, 0, or positive when the point is right,
    collinear, or left from the line, respectively. If the line is horizontal,
    then the returned value is positive.

    Source: http://stackoverflow.com/a/3461533/466781
    """
    a,b = l
    return ((b[0] - a[0]) * (p[1] - a[1]) - (b[1] - a[1]) * (p[0] - a[0]))