def euclidean_distance_point_vs_segment(point, segment):
    """
    Give minimum euclidean distance betwen point and segment

    adapted from : https://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment

    Much more faster than point_vs_segment_distance
    """
    (x1, y1), (x2, y2) = segment
    x3, y3 = point
    px = x2 - x1
    py = y2 - y1
    something = px * px + py * py
    u = ((x3 - x1) * px + (y3 - y1) * py) / float(something)
    if u > 1:
        u = 1
    elif u < 0:
        u = 0
    x = x1 + u * px
    y = y1 + u * py
    dx = x - x3
    dy = y - y3
    dist = (dx * dx + dy * dy) ** 0.5
    return dist
