def point2LineDist2D(x, y, a, b):
    """ distance from point (x, y) to a line defined by a and b
    """
    ax, ay = a[0], a[1]
    bx, by = b[0], b[1]

    d = abs((by - ay)*x - (bx - ax)*y + bx*ay - by*ax)/ ((by - ay)**2 + (bx - ax)**2)**0.5

    return d