我已经阅读了关于这个主题的所有内容,但是我没有设法将部分代码翻译成我理解的简单python .
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,那就太好了 .