I’m looking for an algorithm to insert a new control point on a Bézier curve, without deforming.
Does anybody know a library or reference for Bézier algorithms (insertion, optimize, de Casteljau …)?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is called the “knot insertion problem”. For Bézier curves, the de Casteljau algorithm will give you the right answer. Here is the simple algorithm for a degree 3 Bézier.
Say you want to insert a knot at a fraction
tof the parameter space inside the Bézier curve defined byP0, P1, P2, P3. Here’s what you do:Then your first Bézier will be defined by:
P_0, P0_1, P01_12, P0112_1223; your second Bézier is defined by:P0112_1223, P12_23, P2_3, P3.The geometrical interpretation is simple: you split each segment of the Bézier polygon at fraction
t, then connect these split points in a new polygon and iterate. When you’re left with 1 point, this point lies on the curve and the previous/next split points form the previous/next Bézier polygon. The same algorithm also works for higher degree Bézier curves.Now it can get trickier if you want to insert the control point not at a specific value of
tbut at a specific location in space. Personally, what I would do here is simply a binary search for a value oftthat falls close to the desired split point… But if performance is critical, you can probably find a faster analytic solution.