Polynomial Curves

Change of Basis

This script implements a change of basis between the monomial and the Bernstein representation of polynomial curves, that is, given the control point in terms of one basis, the script computes the control points in terms of the other basis. the A change of basis is a vector space is as follows:

Let \(\{\mathbf{b}_i\}\) and \(\{\mathbf{d}_i\}\) be two basis of the same vector space. Then each \(\mathbf{b}_i\) can be represented as linear combination: \[ \mathbf{b}_i = \sum_j a_{ij}\mathbf{d}_j; \; \text{or short as} \; \mathbf{b} = \mathbf{A}\cdot \mathbf{d} \]. Then the transpose of \(\mathbf{A}\) transforms the coefficients in the following way: Given two linear combinations representing one vector \(\mathbf{v}=\sum_i\,\beta_i\,\mathbf{b}_i=\sum_i\,\delta_i\,\mathbf{d}_i\) then \[ \left(\begin{matrix} \vdots \\ \delta_i \\ \vdots\end{matrix}\right) = \mathbf{A}^T\,\left(\begin{matrix} \vdots \\ \beta_i \\ \vdots \end{matrix}\right) \]

Note: if we use the Berstein basis, then we have a Bézier curve

Monomial and Berstein basis for degree \(n = 3\) \begin{align*} \left(\begin{matrix}B^3_0(u) \\B^3_1(u)\\B^3_2(u)\\B^3_3(u)\end{matrix}\right) & = \left(\begin{matrix} 1 & -3 & 3 &-1 \\ 0 & 3 & -6 & 3 \\ 0 & 0 & 3 &-3 \\ 0 & 0 & 0 & 1 \\ \end{matrix}\right) \\ & = A \times \left(\begin{matrix}1\\u\\u^2\\u^3\end{matrix}\right) \end{align*}


The JavaScript Code