Algorithm for deriving control points of a bezier curve from points along that curve? -
i've been looking for, not finding, algorithm allow me plug in list of x,y coordinates known along curve 4 control points cubic bezier curve spit out.
to more precise, i'm looking algorithm give me 2 control points required shape curve while inputting series of discrete points including 2 control points determine start , end of curve.
thanks!
edit: okay, due math, old foe, need ask bezier curve of best fit polynomial function.
so assume endpoints fixed, , have number of (x,y) sample points want fit cubic bezier.
the number of sample points have determine approach take. let's through few cases:
2 points
2 sample points simplest case. gives total of 4 points, if count end points. number of cvs in cubic bezier. solve this, need parameter (t) value both of sample points. have system of 2 equations , 2 points need solve, equation parametric equation of bezier curve @ t values you've chosen.
the t values can whatever like, better results using either 1/3 , 2/3, or looking @ relative distances, or relative distances along baseline, depending on data.
1 point
this similar 2 points, except have insufficient information uniquely determine degrees of freedom. suggest fit quadratic bezier, , degree elevate. wrote detailed example of quadratic fitting in this question.
more 2 points
in case, there isn't unique solution. have used least-squares approximation results. steps are:
- pick t values each sample
- build system of equations matrix
- optionally add fairing or other smoothing function
- solve matrix least-squares solver
there description of these steps in free cagd textbook, chapter 11. talks fitting b-splines, cubic bezier type of b-spline (knot vector 0,0,0,1,1,1 , has 4 points).
Comments
Post a Comment