📅  最后修改于: 2022-03-11 14:46:42.381000             🧑  作者: Mango
def bezier_curve(def_points, speed=0.01): # WARNING: May run into floating-point issues
n = len(def_points)
points = []
for t in [_ * speed for _ in range(int((1 + speed * 2) // speed))]:
points.append([sum(math.comb(n - 1, i) * ((1 - t) ** (n - 1 - i)) * (t ** i) * def_points[i][0] for i in range(n)), sum(math.comb(n - 1, i) * ((1 - t) ** (n - 1 - i)) * (t ** i) * def_points[i][1] for i in range(n))])
return points