Also, this conversion doesn’t seem like something anyone should do by hand (e.g. adding extra control points which don’t change the curve): some algorithm is going to be able to optimize curves to minimize points, convert between curve types, etc. much better than a human is, and much much faster. [Though for all I know some existing software has crappy implementations]
Personally, I’d recommend people use Raph Levien’s Spiro curves to design their fonts (and not use Béziers directly); they make it much much easier to make whatever shape the designer is actually trying to make. (Folks on Hacker News interested in the mathematics of curve drawing should also definitely check out his PhD thesis.) http://www.levien.com/spiro/
Isn't it the other way around? I mean, isn't cubic a special case of quadratic?
Please correct me if I'm wrong (or my references), I want this article to be as accurate as possible!
Thanks!
We can demonstrate this by looking at the equation for a quadratic Bézier:
(1 - t)^2 P_0 + 2(1 - t)t P_1 + t^2 P_2
Now, let's increase the degree. = [ (1 - t)^2 P_0 + 2(1 - t)t P_1 + t^2 P_2 ] * [ 1 - t + t ]
clearly this equation is equal to the above one because 1-t+t == 1 and multiplying by one does nothing. = [ (1 - t)^2 P_0 + 2(1 - t)t P_1 + t^2 P_2 ] * [ (1 - t) + t ]
= (1 - t)^3 P_0 + t(1 - t)^2 P_0 + 2(1 - t)^2t P_1 + 2(1 - t)t^2 P_1 + (1 - t)t^2 P_2 + t^3 P_2
Group by powers of t: = (1 - t)^3 P_0 + t(1 - t)^2 [P_0 + 2*P_1] + (1 - t)t^2 [2P_1 + P_2] + t^3 P_2
Which is exactly a cubic Bezier curve.Thus, all quadratic Beziers can represented cubic ones, but the reverse does not hold, thus quadratics are specializations of cubics.
QED.
This is known as degree elevation.
I'm not very math savvy and I was trying to get this right.
Anyway, thank you very much for making this clear!
Cheers!
> But if we were to write one to convert quadratic to cubic, the best the program could do is an approximation of the original outline, usually keeping the anchor points it already had, but adding one more control point per anchor.
Isn't quadratic just a special case of cubic? i.e. a cubic curve with C1 == C2. It does add one more control point per curve (so it's bad for the overall size of the drawing) but it's not an approximation, it's the exact same curve. It also seems like a much simpler conversion than the other way around.