def interpolate(edge, x):
    """Given a sorted edge ((x1, y1), (x2, y2)) and an x value x,
    return a vertex (x, y') where y' is on the given edge.
    """
    t = (x - edge[0][0]) / (edge[1][0] - edge[0][0])
    y_prime = edge[0][1] + t * (edge[1][1] - edge[0][1])
    return x, y_prime