# How to find the N control point of a bezier curve with N+1 points on the curve

I have a the set of points my curve has to pass through, 2 of those are the start and end points. I'm looking for a way to find the control points of my bezier curve (mostly quadratic and cubic) by using points on the curve.

ex: I have 4 points: start,end and 2 points on the curve, the first and last control point are the start and end point but how do I determine the middle control point.

Can I do the same with a cubic bezier curve and 5 points ? (start,end and 3 on the curve)

I cannot use spline interpolation because the tool I'm using only allows for bezier curves.

thank you all

EDIT: so far it got:
I have 4 points on the curve, [$C_0,C_1,C_2,C_3$]
since first and last are control points: $[Q_0=C_0, Q_2=C_3]$
Bezier equation: $B(t)=(1-t)^2*Q_0+2(1-t)*t*Q_1+t^2*Q_2$
From this I can make 2 equation:
$C_1=(1-t_1)^2*Q_0+2(1-t_1)*t_1*Q_1+t_1^2*Q_2$
$C_2=(1-t_2)^2*Q_0+2(1-t_2)*t_2*Q_1+t_2^2*Q_2$
which is 2 equation, 3 unknown (infinite possiblity) adding more points from the curve would give me n equation with n+1 unknown.
Maybe I'm wrong and there's no way to calculate the control points from just points on the curve (and no t value, the percentage along the curve at which they are located)

EDIT 2: Is there a way to find the control points WITHOUT EVER specifying the $t$ values? I can provide as many point on the curve as needed but assigning $t$ values to these points would be very imprecise. (I'm trying to model curves of a real life object). Unless I'm wrong, There is only 1 set of control points that generate a certain curve

• Regarding your edit2: see the last paragraph of my answer, plus the other answer that it links to. – bubba Oct 15 '14 at 13:43

The simplest approach is to use $N+1$ points to construct a curve of degree $N$. You have to assign a parameter ($t$) value to each point. So, to construct a cubic curve through four given points $\mathbf{P}_0$, $\mathbf{P}_1$, $\mathbf{P}_2$, $\mathbf{P}_3$, you need four parameter values, $t_0, t_1, t_2, t_3$. Then, as @fang said in his answer, you can construct a set of four linear equations and solve for the four control points of the curve. Two of the equations are trivial, so actually you only have to solve two equations.

The simplest approach is to just set $$t_0 = 0 \quad , \quad t_1 = \tfrac13 \quad , \quad t_2 = \tfrac23 \quad , \quad t_3 = 1$$ Then the matrix in the system of linear equations is fixed, and you can just invert it once, symbolically. You can get explicit formulae for the control points, as given in this question. But this only works if the given points $\mathbf{P}_0$, $\mathbf{P}_1$, $\mathbf{P}_2$, $\mathbf{P}_3$ are spaced fairly evenly.

To deal with points whose spacing is highly uneven, the usual approach is to use chord-lengths to calculate parameter values. So, you set $$c_0 = d(\mathbf{P}_0, \mathbf{P}_1) \quad ; \quad c_1 = d(\mathbf{P}_1, \mathbf{P}_2) \quad ; \quad c_2 = d(\mathbf{P}_2, \mathbf{P}_3)$$ Then put $c = c_0+c_1+c_2$, and $$t_0 = 0 \quad , \quad t_1 = \frac{c_0}{c} \quad , \quad t_2 = \frac{c_0+c_1}{c} \quad , \quad t_3 = 1$$

Then, again, provided $t_0 < t_1 < t_2 < t_3$, you can set up a system of linear equations, and solve.

If you're willing to do quite a bit more work, you can actually construct a cubic curve passing through 6 points. Though, in this case, you can't specify the parameter values, of course. For details, see my answer to this question.

In general, you can find the Bezier curve of degree N passing through given (N+1) distinct points. You have to assign proper parameters to each point first and solve a linear equation set. However, differnet parameter assignments will generate different result. If you have more points than the order of the Bezier curve ( order = degree + 1), then you can find a Bezier curve that comes close to the given points using methods such as least square fitting.

• Good answer, except for a small quibble: the $N+1$ given points don't need to be distinct. – bubba Oct 14 '14 at 4:41
• @bubba: If you somehow can assign distinct parameters to the points with same coordinates, then the points do not need to be distinct. But most good parametrization scheme are derived from distance between points (such as chord-length or centripental parametrization). In this sense, you do need distinct points to get good parametrization. – fang Oct 14 '14 at 6:03
• Yes, it's the parameter values that need to distinct. – bubba Oct 14 '14 at 13:51