I am developing an application that renders ECG rhythms that need to be animatable in response to user input. That part is not relevant to this site3, however I am starting with hand drawn rhythms, determining their polynomial representation and need to determine a bezier representation of those polynomials, which is the reason I am asking the question here. ( I can draw the rhythms using software like adobe illustrator, however the representation is not predictable and in order to animate them the bezier representation has to fit a certain format, so illustrator and the like are not an option, only drawing them by hand is).
So the question I need help with is, given a curve how can you derive the control points of its bezier representation? for example, if I wished to derive the bezier representation of a parabola:
$$F(x) = x^2, \:\: \{-2 \leq x \geq 2\}$$
with a parameterization such as:
$$F(t) = (4t -2)^2, \:\: \{0 \leq t \geq 1\} $$
what is method of obtaining the bezier coefficients for $F(t)$?
The equation of a Bézier curve is $$P(t) = \sum_{k=0}^n \binom{n}{k} (1-t)^{n-k} t^k P_k = \sum_{k=0}^n \binom{n}{k} \sum_{j=0}^{n-k} \binom{n-k}{j} (-t)^j t^k P_k $$ So if you have an expression for $P(t)$ in the form $$P(t) = \sum_{i=0}^n t^i A_i$$ you can equate coefficients of powers of $t$ to get simultaneous linear equations which you can solve for the $P_k$.
Your example is a quadratic, so $n = 2$ and $$\begin{eqnarray} P(t) &=& \binom{2}{0}(1-t)^2 t^0 P_0 + \binom{2}{1}(1-t)^1 t^1 P_1 + \binom{2}{2}(1-t)^0 t^2 P_2 \\ &=& (1-2t+t^2) P_0 + (2t-2t^2) P_1 + t^2 P_2 \\ &=& t^2 (P_0 - 2 P_1 + P_2) + t(-2 P_0 + 2 P_1) + P_0 \\ \end{eqnarray}$$ If we equate coefficients with the general quadratic $P(t) = t^2 A_2 + t A_1 + A_0$ we get $$\begin{eqnarray} P_0& & &=& A_0 \\ -2P_0& + 2P_1& &=& A_1 \\ P_0& - 2P_1& + P_2 &=& A_2 \\ \end{eqnarray}$$ which we can solve by Gaussian elimination without pivoting to get $$\begin{eqnarray} P_0 &=& A_0 \\ P_1 &=& A_0 + \tfrac12 A_1 \\ P_2 &=& A_0 + A_1 + A_2 \\ \end{eqnarray}$$
This can now be applied separately in the $x$- and $y$-coordinates: $$\begin{eqnarray} x(t) &=& 4t-2 & \implies & x_0 = -2, & x_1 = 0, & x_2 = 2 \\ y(t) &=& (4t-2)^2 & \implies & y_0 = 4, & y_1 = -4, & y_2 = 4 \\ \end{eqnarray}$$ So the Bézier control points are $(-2, 4), (0, -4), (2, 4)$.