# Bezier interpolations

Hi

Sorry if it has been discussed before but after lot of searches , i m still not sure about how to build my transform matrices when it comes to bezier interpolation.

First for the control points computation i ve found different versions ; which one is correct ??
CP(0) = (input[N], output[N])
CP(1) = ((input[N] * 2 + input[N+1]) / 3, output[N] + out_tangent[N] / 3)
CP(2) = ((input[N] + input[N+1] * 2) / 3, output[N+1] - in_tangent[N+1] / 3)
CP(3) = (input[N+1], output[N+1])

CP(0) = (input[N], output[N])
CP(1) = ((input[N] * 2 + input[N+1]) / 3, output[N] + out_tangent[N])
CP(2) = ((input[N] + input[N+1] * 2) / 3, output[N+1] - in_tangent[N])
CP(3) = (input[N+1], output[N+1])

Then for Bezier interpolation is the following formula correct ?
P(t) = A*(1 - t)^3 + 3Bt*(1 - t)^2 + 3Ct^2*(1 - t) + D*t^3
where A,B,C,D are my 4 control points , t the interpolation factor between 0 and 1 , and P the result.

First for the control points computation i ve found different versions ; which one is correct ??
It depends on if you’re talking about animation curves or the geometric curves that show up as part of your scene under the <geometry> element, as they work slightly differently IIRC. I’m going to assume you’re talking about animation curves.

The most up to date description of how the animations are intended to work is given in the Collada 1.4.1 release notes revision B. That document doesn’t seem to use either of the equations you mentioned. Instead they define Bezier curves like this:

``````P0 is (INPUT[i] , OUTPUT[j][i])
C0 (or T0) is (OUT_TANGENT[0][i] , OUT_TANGENT[j][i])
C1 (or T1) is (IN_TANGENT[0][i+1], IN_TANGENT[j][i+1])
P1 is (INPUT[i+1], OUTPUT[j][i+1])

B(s) = P0*(1− s)^3 + 3*C0*s(1− s)^2 + 3*C1*s^2 (1− s) + P1*s^3 ,s ∈ [0,1]
``````

Then for Bezier interpolation is the following formula correct ?
P(t) = A*(1 - t)^3 + 3Bt*(1 - t)^2 + 3Ct^2*(1 - t) + D*t^3
Yes, but you have to keep in mind that t != time (or whatever your input is). Instead you have a curve P(t) = [x(t), y(t)], where x is time and y is the output value. This isn’t exactly the same as your textbook definition of Bezier curves, where you’re given the independent parameter and you evaluate the curve to get a vector. Instead you’re given an x value (the time) and you have to figure out the corresponding t value, and then evaluate the curve with that value to get the corresponding y. These curves come from DCC tool land.

This issue has been discussed in the past. It’s all pretty confusing IMO, and I’m not sure why the designers thought this was the best approach. Collada animations in general are very poorly explained in the spec and the release notes.