def intersection(p1, p2, p3, p4):
    """ Intersection point (x,y) of lines formed by the vectors p1-p2 and p3-p4
        http://paulbourke.net/geometry/pointlineplane/"""
    dp12 = p2 - p1
    dp34 = p4 - p3
    det = float(dp34.y * dp12.x - dp34.x * dp12.y)
    if det == 0.0:
        return None
    else:
        ua = (dp34.x * (p1.y - p3.y) - dp34.y * (p1.x - p3.x)) / det
        return p1 + dp12.__mul__(ua)
