def xy_to_mb(pt1, pt2):
    """convert two points of line into y = mx + b form.
       if line is vertical, return (None, x-intercept)"""
    (x1, y1) = pt1
    (x2, y2) = pt2
    if abs(x1 - x2) > 0.001:
        m = float(y1 - y2) / (float(x1 - x2) + 0.0000001)
        b = y1 - m * x1
    else:
        m, b = None, x1
    return m, b