views:

201

answers:

2

Given a few sample points on a bézier curve, is it possible to work out the set of possible curves these points may lie on?

In my specific application there is a limited set of endpoints the curve may have, so I want to generate the set of possible curves, enumerate all of them and pick out all the ones which may end on a valid end point.

Some people have asked for more detail. I have a set of points which I know are on a quadratic bezier curve, I want to calculate the formula of the curve and be able to extrapolate new points on the curve.

+1  A: 

Here they are: http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Examination_of_cases

FractalizeR
I think it's not that simple. Most of the times, people say *curve* but actually mean many adjacent curves forming a *path*.
Georg
We are talking about very concrete curves here. Exactly bezier curves.
FractalizeR
How would I use this to calculate the set of all possible curves my sample points can lie on?
Martin
+2  A: 

Bezier curves will always go through starting and ending control points.

If the degree of the curve is equal to the number of sample points then there will be only one curve that will pass through all your points (in a normal case, where all points are different and they don't lie on a bezier curve of a lesser degree).

If the degree of a curve is less then the number of the sample points then, in general case, you will not be able to make the curve go through all the points (in a normal case).

If the degree of a curve is higher then the number of the sample points then, in general case, you will be able to draw infinite number of curves.

In the wiki article you will find references to control points only, but still I believe that I remember the above properties correctly and that they hold for the points on the curves as well.

I think you need to redefine your question and exactly define what type of curves (and of which degree) do you need. Also as Georg pointed out you might be looking for paths - a combination of curves.

EDIT: First a correction - curve is defined with degree plus one number of control points points (quadratic need three). Control points are not the same as points on the curve - and for three points on the curve and quadratic curve you could have infinite number of solutions (see this for quadratic curve and four points)

As for the solution (but still under assumption that you are looking at a single curve):

For an equation for single quadratic curve you have

B(t) = (1-t)^2*P0 + 2*(1-t)*t*P1 + t^2*P2

Capital letters above are vectors, and P0 corresponds to starting control point (first point), P2 corresponds to ending control point (last point), so you still need to find P1. The variable t is scalar that ranges from 0 to 1.

If working with 2D curves the above vector equation gives two scalar equations for each point on the curve.

Still there is t as an unknown, so you should take 2 more points (4 in total) which will give you 4 unknowns (t for first point, t for second point, x and y of the P1, middle control point) and 4 equation to solve (2 from each sample point).

Solve that with your favourite numerical method and you will get the original curve on which the points came from.

If you still think that you can get more curves and that you will have to choose something then you are not working with bezier curves, but with bezier splines (in a sense of multiple curves joined together). Still the same principle applies and if you work out a way to solve a single curve from the above equations (and if you have enough points) then you can divide the problem into n-segments of actual bezier curves and solve each as outlined above.

If it turns out that you don't have enough points then look at the linked article again - you are probably looking for the smoothest curve and there are some suggestions in the article on how to get there as looking for the exact solution (shortest curve/smoothest curve) seems to be rather complex.

Unreason
I added a little extra to the question as you asked :)
Martin
I added a little extra to the answer I provided :)
Unreason
Thanks, this looks pretty good. I'll see about trying it out in the next few days.
Martin