Bezier curve polynomial coefficients

3.1k Views Asked by At

How can I calculate coefficients for Bezier polynomial? I can do this manually on the paper, but I need to plug this into program, where degree of polynomial can be higher than 3 (more than 4 control points). Is there some universal scheme, like eg. Pascal triangle, to evaluate coefficients ?

1

There are 1 best solutions below

3
On BEST ANSWER

Yes, there is. Take a look at this section on the Wikipedia page of the topic. The coefficients can be calculated as follows:

$$\mathbf C_j=\frac{n!}{(n-j)!}\sum_{i=0}^j\frac{(-1)^{i+j}\mathbf P_i}{i!(j-i)!}$$

Here $n$ is the order of the curve, $\mathbf C_j$ is the coefficient of the $j$-th power term in the polynomial and $\mathbf P_i$ is the $i$-th control point. The page warns of the numeric instability of the direct formula for high order curves and points to De Casteljau's algorithm, if this is a problem.

Note that you can optimize some of the calculations here. For example, rather than computing the factorials $n!$ and $(n-j)!$ and taking their ratio, you can simply take the product of the integers $(n-j+1), (n-j+2),\dots,n$. This will also probably be more accurate.