def _point_in_polygon(point, polygon, constants, factors):
    """
    Test if a point is in a polygon.
    """

    x, y = point
    npoints = polygon.shape[0]

    in_poly = False
    current = polygon[npoints-1, 1] > y

    for i in range(npoints):
        previous = current
        current = polygon[i, 1] > y
        if current != previous:
            in_poly ^= (y*factors[i]+constants[i] < x)

    return in_poly