[ Bezier curve is straight ]
I would like to draw a Bezier curve, I use 4 control points, but my line is still straight.
I have a class which handle points. I use pyglet to draw the output.
def Bezier(P0,P1,P2,P3, t): t2 = t*t t3 = t2 * t mt = 1-t mt2 = mt * mt mt3 = mt2 * mt P0.mulP(mt) P1.mulP(3) P1.mulP(mt2) P1.mulP(t) P2.mulP(mt) P2.mulP(3) P2.mulP(t2) P3.mulP(t3) P0.addP(P1) P0.addP(P2) P0.addP(P3) return P0
Edit: I'm still playing around with this issue. I have a function to calculate the coordinates of the Bezier curve, it shows the same thing...
def Bezier3deg(P0,P1,P2,t): ReP = points.point() t1 = (1 - t) * (1 - t) P0.mulP(t1) t2 = 2 * (1-t) * t P1.mulP(t2) t3 = t*t P2.mulP(t3) ReP.addP(P0) ReP.addP(P1) ReP.addP(P2) return ReP
Okay, I figure it out, that the problem was my python skill. The Bezier function always changed the original coordinates of the control points. After I fixed it, the curves are fine.