def point_on_line(point, seg_p1, seg_p2, tol=1e-6):
    """Determines whether a point lies on a line segment

    Allows for a small tolerance

    Args:
        point ([float, float]): the point to test
        seg_p1 ([float, float]): the beginning of the line segment
        seg_p2 ([float, float]): the end of the line segment
        tol (float): the maximum distance of the point from the 1d line

    Returns:
        bool indicating whether the point lies within tol of the line
    """
    # Special case: vertical lines:
    if seg_p1[0] == seg_p2[0]:
        if point[0] != seg_p1[0]:
            return False
        else:
            miny = min(seg_p1[1], seg_p2[1])
            maxy = max(seg_p1[1], seg_p2[1])
            return miny <= point[1] <= maxy
    prop_along = (point[0] - seg_p1[0]) / (seg_p2[0] - seg_p1[0])
    if prop_along < 0 or prop_along > 1:
        return False
    guess_y = seg_p1[1] + prop_along * (seg_p2[1] - seg_p1[1])
    return abs(guess_y - point[1]) < tol