我已經閱讀了一切,我可以在這裏找到關於這個主題,但我沒有設法將部分代碼翻譯成簡單的Python我會明白。Python - 均勻分佈貝塞爾曲線上的對象
我得到這個基礎上德卡斯特里奧算法的this very good explanation:
def divideCurve(p0, cp0, cp1, p1, t):
# p0 and p1 are the start/end points of the bezier curve,
# cp0 and cp1 are the control points
# all points are tuples of their coordinates: p0 = (10, 15)
Ax = ((1 - t) * p0[0]) + (t * cp0[0])
Ay = ((1 - t) * p0[1]) + (t * cp0[1])
Bx = ((1 - t) * cp0[0]) + (t * cp1[0])
By = ((1 - t) * cp0[1]) + (t * cp1[1])
Cx = ((1 - t) * cp1[0]) + (t * p1[0])
Cy = ((1 - t) * cp1[1]) + (t * p1[1])
Dx = ((1 - t) * Ax) + (t * Bx)
Dy = ((1 - t) * Ay) + (t * By)
Ex = ((1 - t) * Bx) + (t * Cx)
Ey = ((1 - t) * By) + (t * Cy)
Px = ((1 - t) * Dx) + (t * Ex)
Py = ((1 - t) * Dy) + (t * Ey)
print Px, Py
for T in range(0, 11, 1):
t = T*0.1
divideCurve(p0, cp0, cp1, p1, t)
但這沿曲線分佈不均的點。
我認爲here是一個可能的解決方案,但我完全不明白弧長函數的反函數或如何將其轉換爲python的代碼。 我發現另一種方法here,我認爲它採取了不同的方法,我再也不明白在python中實現的足夠了。
如果有人願意澄清這個簡單的python,那會很棒。