We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexSuggestions & BugsSoftware,  Documentation,  Website Suggestions › quadratic bezier from cubic bezier
Page Index Toggle Pages: 1
quadratic bezier from cubic bezier (Read 1404 times)
quadratic bezier from cubic bezier
Jun 15th, 2009, 1:51am
 
It has been suggested in the forums as well as in the developer docs that to get a quadratic bezier from Processing's cubic bezier all you have to do is take the two control points to be the same. This is not correct.
To get a quadratic bezier with anchor points (x1,y1) and (x2,y2) and control point (cx,cy), you have to construct the cubic bezier with anchor points (x1,y1) and (x2,y2) and control points (cx1,cy1) = ( (x1 + 2*cx)/3 , (y1 + 2*cy)/3 ) and (cx2,cy2) = ( (2*cx + x2)/3 , (2*cy + y2)/3).
Since this is my first message, I am not allowed to post the link to where I got this information.
But the parametric equation of the quadratic bezier is this:
p(t) = (1-t)2p0 + 2t(1-t)p1 + t2p2, where p0 and p2 are the anchor points and p1 is the control point.
For a  cubic bezier the equation is
p(t) = (1-t)3 p0 + 3 t (1-t)2 p1 + 3 t2(1-t) p2 + t3p3, where p0 and p3 are the anchor points and the other two the control points.

With the above subtitution one can verify that the cubic bezier does give the quadratic bezier.
Page Index Toggle Pages: 1