You probably already know this, but let me explicitly point out:
== exact match ==
It is not possible to construct a single cubic Bezier curve that exactly matches your new curve.
A single cubic Bezier curve has a constant "curvature" A along its length.
When you shrink it, the new curve has "sharper" curvature B (but still constant along the length of the new curve).
It is not possible to construct a single cubic Bezier curve -- since, like all single cubic curves, it has constant curvature C along its length -- such that C=A along the part of the length, and C=B along the rest of the length, where A<>B.
(I'm mis-using the term "curvature" here for something that is more precisely the 3rd derivative of a curve, sometimes called the "jerk").
== approximation ==
Perhaps the simplest approximation is:
Use the initial starting point and first control knot -- p0 and p1,
and the final control knot and final ending point -- r'2 and r'3.
Use those 4 points as the start, control knots, and endpoint of a Bezier curve that approximates the one you want: a0, a1, a2, a3.
This approximation exactly hits the endpoints of your desired curve, and has the same initial and final slope at those endpoints, but it slightly diverges from your desired curve in the middle.
In particular, it probably doesn't go exactly through the cutpoint K.
There are many other possible approximations you could make.
The "Don Lancaster's Guru's Lair Cubic Spline Library"
may have the details I'm leaving out:
- It is possible to nudge a1 along the line p0-p1, or to nudge a2 along the line r'2-r'3 -- or both -- such that the approximation curve not only starts and ends at the same points and slopes, but also passes through the cutpoint K.
- pick any 4 points along your new curve (perhaps the endpoints, the cutpoint K, and some other point) and generate a cubic Bezier curve that goes exactly through all 4 points.
- pick many points along your new curve -- bunched together in places where curve matching is important, perhaps near the endpoints and point K, and spaced further apart where curve matching is not so important -- and generate a cubic Bezier curve that is a least-squares best fit to those points.
You can see that it will be difficult to solve this satisfactorily by considering the case where the points to be interpolated are at the extrema of a sinusoidal curve. Any reasonable solution should have horizontal tangents at the points, but this is not possible with quadratic curves.
Peter has described how to achieve continuity of the tangents with many arbitrary choices. You can reduce those choices to a single choice by requiring continuity in the derivatives, not just their directions (which determine the tangents). This looks nice formally, but it can lead to rather wild curves, since a single choice of control point at one end then determines all the control points (since you now have to take equal steps on both sides of the points in Peter's method), and these may end up quite far away from the original points – again, take the case of the extrema of a sinusoidal; this will cause the control points to oscillate more and more as you propagate them.
What I would try in order to get around these problems, if you really have to use quadratic Bézier curves, is to use some good interpolation method, e.g. cubic splines, and calculate intermediate points between the given points, along with tangent directions at the given points and the intermediate points. Then you can draw quadratic Bézier curves through all the points, given and intermediate, and determine control points by intersecting the tangents. This wouldn't work without the intermediate points, because the tangents might not intersect at reasonable points – again, think of the extrema of a sinuisoidal, where the desired tangents are in fact parallel – but I think it should work with the intermediate points – for instance, in the sinusoidal example, the intermediate points would be at the inflection points of the sinusoidal, and the tangents would intersect at suitable control points.
Best Answer
This is a common problem, of course, because people are always trying to convert Postscript fonts (which use cubic curves) into TrueType ones (which use quadratic curves).
To answer your question, I don't think there is any accepted "gold standard" approach.
Many of the algorithms you'll find on the net are heuristic. The developer thinks his results "look good", and that's the end of the analysis. If you want to be more rigorous, then you have to define "good" or "best" in order to find the best algorithm. Lets call the original cubic $C$ and the approximating piecewise quadratic $Q$. Then some possible criteria of goodness are:
and so on.
No matter what criteria you decide to choose, the "test-and-reduce" meta-algorithm you mentioned is reasonable: take two points on the cubic, and use these points and their tangent vectors to construct a quadratic. If the quadratic is acceptable (according to whatever criteria you decided), you're done; if not, choose two points that are closer together. Rinse and repeat.
Regardless of what @Timo said, there is no way to exactly represent a cubic curve as a string of quadratic ones unless the cubic curve was, (by some miraculous stroke of luck) a disguised quadratic in the first place. The string of quadratics you construct will be merely be an approximation of the cubic; all you can do is ensure that it's a "good" approximation.