def in_segment(point, line):
    """Determine if a point is inside a segment, if we already know that
    the point is on the infinite line defined by the segment.
    """
    if line[0].x != line[1].x:  # line is not vertical
        if line[0].x <= point.x <= line[1].x:
            return True
        if line[1].x <= point.x <= line[0].x:
            return True
    else:  # line is vertical, so test the y coordinate
        if line[0].y <= point.y <= line[1].y:
            return True
        if line[1].y <= point.y <= line[0].y:
            return True