#### hotvette

Homework Helper

- 988

- 3

Does anyone know how to fit a cubic Bezier curve to a given set of data points? If so, I'd appreciate some coaching on the methodology.

Bezier curves have separate equations for x and y in a parametric variable t that varies from 0 to 1:

the 8 unknowns are a function of 4 control points:

x

y

thus, for a given set of values for the 4 control points, all 8 coefficients are determined and the x,y values of the Bezier curve can be calculated.

But, the equations are de-coupled in the sense that a,b,c,d depend ONLY on the x-values of the 4 control points (x

I've been trying (in vain so far) to set up the curve fitting as a least squares problem. Part of the problem is the difficulty of finding the right value of t for a given x of a data point being fitted, since x is cubic in t. One approach is to solve the cubic equation, but I've found that Newton-Raphson works quite well.

It turns out that solving for the y-values of the 4 control points (y

The problem is how to get updated x-values of the control points (x

I've searched the internet extensively and though have found references to least squares solutions to Bezier curves, I've never found enough detail to figure out how to do it.

Any/all hints/tips would be appreciated. Perhaps an approach other than least squares is better. Thanks!

Bezier curves have separate equations for x and y in a parametric variable t that varies from 0 to 1:

**x = at**^{3}+ bt^{2}+ ct + d*y = et*^{3}+ ft^{2}+ gt + hthe 8 unknowns are a function of 4 control points:

x

_{c}= (x_{0}, x_{1}, x_{2}, x_{3})y

_{c}= (y_{0}, y_{1}, y_{2}, y_{3})thus, for a given set of values for the 4 control points, all 8 coefficients are determined and the x,y values of the Bezier curve can be calculated.

But, the equations are de-coupled in the sense that a,b,c,d depend ONLY on the x-values of the 4 control points (x

_{c}) and e,f,g,h depend ONLY on the y-values of the 4 control points (y_{c}).I've been trying (in vain so far) to set up the curve fitting as a least squares problem. Part of the problem is the difficulty of finding the right value of t for a given x of a data point being fitted, since x is cubic in t. One approach is to solve the cubic equation, but I've found that Newton-Raphson works quite well.

It turns out that solving for the y-values of the 4 control points (y

_{c}) is a straightforward linear least squares problem because the equations are linear in y_{c}. Thus, for an initial guess of the x-values of the control points (x_{c}) the values of t for each data point can be determined (e.g. by Newton-Raphson), and in a single least squares calculation, the y-values of the control points (y_{c}) can be determined to minimize the square error in vertical distance between the data points and the calculated curve.The problem is how to get updated x-values of the control points (x

_{c}).I've searched the internet extensively and though have found references to least squares solutions to Bezier curves, I've never found enough detail to figure out how to do it.

Any/all hints/tips would be appreciated. Perhaps an approach other than least squares is better. Thanks!

Last edited: