def approximate_cubic_bezier(p0, p1, p2, p3, threshold=1.0, limit=1024):
    threshold_squared = threshold ** 2
    points = {  # dict mapping t values to points
        0.0: p0,
        1.0: p3,
    }
    to_check = deque([(0.0, 1.0)])
    while len(to_check) > 0 and len(points) < limit:
        l, r = to_check.popleft()
        pl = points[l]
        pr = points[r]
        m = (l + r) / 2.0
        pm = cubic_bezier_point(p0, p1, p2, p3, m)
        if square_distance_to_segment(pm, pl, pr) > threshold_squared:
            points[m] = pm
            to_check.append((l, m))
            to_check.append((m, r))
    return [points[t] for t in sorted(points.keys())]
Return an series of points whose segments approximate the given
dataset/ETHPy150Open Microsoft/ivy/ivy/dot_layout.py/approximate_cubic_bezier