# Forcing Bezier Interpolation

I found this very informative site that discusses forcing bezier interpolation and the site gives formulae for calculating the control points so that the curve goes through a set of four points, y0, y1, y2 and y3, for t=0, 1/3, 2/3, 1 respectively.

The formulae given on this site are as follows:

P0 = y0
P1 = ( -5 * y0 + 18 * y1 -  9 * y2 + 2 y3 ) / 6
P2 = (  2 * y0 -  9 * y1 + 18 * y2 - 5 y3 ) / 6
P3 = y3


What I am looking for is a more general form of the formulae for calculating P1 and P2. So instead of having fixed values of t of 1/3 and 2/3, rather to express them as a function of t1 and t2, where t1 is the value of t for point y1 and t2 is the value of t for y3. Can someone please help in deriving these more general formulae?

-
How much do you know about Bézier curves? In particular, do you know a general formula for the point at a given value of $t$? –  Peter Taylor May 16 at 9:09
Hi Peter. I don't know that much about Bezier curves. I am actually a programmer and this is the first time I am having to deal with curves; so trying to figure this stuff out. I have read the general formula, but can't say I understand it. You can look at my question here stackoverflow.com/questions/16491180/… to see what I am trying to accomplish. The formula that I posted here does work and the curve goes through the points, but the positioning on the curve at t=1/3 and t=2/3 is not ideal. –  BruceHill May 16 at 11:20
Oh, and I realize my question on stackoverflow shows a quadratic curve... I solved the problem stated in this question for quadratic curves and now am trying to solve for cubic bezier curves. –  BruceHill May 16 at 11:26

Without going into the full theoretical background, Bézier curves use a set of polynomials called Bernstein polynomials to weight the points. For a cubic Bézier, which seems to be what your question is about, this results in the parametric definition $$P(t) = (1-t)^3 P_0 + 3t(1-t)^2 P_1 + 3t^2(1-t) P_2 + t^3 P_3$$

When $t = 0$ this gives simply $P(0) = P_0$, and similarly $P(1) = P_3$. So we only have two degrees of freedom in forcing the curve to pass through your intermediate control points. As the site you linked mentioned, we can set up simultaneous equations:

$$\begin{eqnarray*} & P_0 & & & & & = & y_0 \\ (1-t_1)^3 & P_0 & + 3t_1(1-t_1)^2 & P_1 + 3t_1^2(1-t_1) & P_2 + t_1^3 & P_3 & = & y_1 \\ (1-t_2)^3 & P_0 & + 3t_2(1-t_2)^2 & P_1 + 3t_2^2(1-t_2) & P_2 + t_2^3 & P_3 & = & y_2 \\ & & & & & P_3 & = & y_3 \end{eqnarray*}$$

which easily reduce to

$$\begin{eqnarray*}3t_1(1-t_1)^2 & P_1 + 3t_1^2(1-t_1) & P_2 & = & y_1 - (1-t_1)^3 y_0 - t_1^3 y_3 \\ 3t_2(1-t_2)^2 & P_1 + 3t_2^2(1-t_2) & P_2 & = & y_2 - (1-t_2)^3 y_0 - t_2^3 y_3 \end{eqnarray*}$$

I assume you can take it from here.

-
I will have to brush up a bit on solving simultaneous equations, but yes, I can take it from here. Thanks, Peter. –  BruceHill May 16 at 11:49
First, if you try somewhat harder, you can actually get a planar cubic Bezier curve to interpolate six points, not just four. As you have realized, when interpolating four points, you have to make up parameter values for two of them. The standard choices are $\tfrac13$ and $\tfrac23$, but there's nothing magic about these -- you can use any values you like, and you'll still be able to solve the simultaneous equations and get a curve. But the shape of this curve is highly dependent on the choice you make, so it would be better if you didn't have to make it. By providing another two points, you can remove this troublesome choice. The details are described in this paper. It's probably more complicated than you need, right now, but maybe useful some day.
For fitting four points with prechosen t it suffices to solve two simultaneous linear equations in two variables, which is something people learn at age around 15 in my country, whereas Lagrange form isn't covered in the standard school syllabus at all. That paper's interesting, though: I've added it to my list of things to read. –  Peter Taylor May 17 at 10:19