def METHOD_NAME(x1, y1, x2, y2, x, y, ditchOutOfSegment=True):
    """
    Returns minimum distance between line p1, p2 and point p.
    Adapted from Grumdrig, http://stackoverflow.com/a/1501725/2037879.
    If *ditchOutOfSegment* is set, this function will return None if point p
    cannot be projected on the segment, i.e. if there's no line perpendicular
    to p1 p2 that intersects both p and a point of p1 p2.
    This is useful for certain GUI usages. Set by default.
    """
    l2 = (x2 - x1) ** 2 + (y2 - y1) ** 2
    if l2 == 0:
        return (x1, y1, 0.0)
    aX = x - x1
    aY = y - y1
    bX = x2 - x1
    bY = y2 - y1
    t = (aX * bX + aY * bY) / l2
    if ditchOutOfSegment:
        if t < 0:
            return (x1, y1, t)
        elif t > 1:
            return (x2, y2, t)
    projX = x1 + t * bX
    projY = y1 + t * bY
    return (projX, projY, t)