1

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)$?

user74091
  • 365

1 Answers1

1

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)$.

Peter Taylor
  • 13,425
  • And since this is for a graphic essentially and I don’t care about time, I have the freedom to pick any arbitrary number for T then? – user74091 Nov 22 '19 at 23:20
  • If you pick a value of $t$ you collapse the polynomial to a point. It's not "time" but "independent variable". – Peter Taylor Nov 23 '19 at 06:56
  • i updated my question above, could you elaborate a bit more on your instruction? i included an example above and i believe you are stating i make linear equations from the coefficients for $F(t)$ , which in this case would be 16, -16, and 4, but how exactly i do that i dont know – user74091 Nov 23 '19 at 17:02
  • im sorry if this sounds like a bad student question but i am actually needing this for an application i am developing that involves taking arbitrarily complex polynomials and generating a bezier representation of in a certain format and under certain (programming) constraints, so i have a need to 'draw' them by hand and this is a bit out of my depth – user74091 Nov 23 '19 at 17:07
  • I've worked that example, and in fact all quadratic examples, and I hope you can see how to apply the same approach to higher degrees. – Peter Taylor Nov 23 '19 at 19:41
  • ok, yes i follow your example. another question, [mdn[(https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#Path_commands) shows the different path commands for svg, which are bezier curves. you drawing second order polynomials with either the cubic or quadratic bezier curves. so, in the example above, would A1 have two definitions for the two different control points, or how does that work? – user74091 Dec 14 '19 at 03:41
  • If you're expressing a quadratic as a cubic then $A_3 =(0, 0)$ – Peter Taylor Dec 14 '19 at 07:47
  • I'm going to open a separate question, but before I do let me make sure I have this right, performing the same technique for n = 3 then $$ P_0 = A_0 ;; P_1 = A_0 + A_1/3 ;;P_2 = 3A_0 + 2A_1 + A_2 ;; P_3 = 13A_0 + 3A_1 + 3*A_2 + A_3$$ – user74091 Dec 15 '19 at 03:19