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.
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:
- The maximum distance between $C$ and $Q$ is small
- The maximum value of $\|C(t) - Q(t)\|$ is small. This is not the same thing as #1.
- The maximum angle between $C'(t)$ and $Q'(t)$ is small
- Tangent discontinuities in $Q$ are small (perhaps even zero)
- $Q$ and $C$ have the same turning points (important for font hinting)
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.
Best Answer
If the two Bézier curves came from splitting one, then the geometry must look like this:
We know the blue points: $A$, $B$, $C$, $D$ are the control points of the first curve, and $D$, $E$, $F$, $G$ are the control points of the second one.
First, find $k$ such that $E = D + k(D-C)$. We know this $k$ exists because we’re assuming a smooth joint. Then compute the red points $P$, $Q$, $R$, $S$, $T$ as follows:
If $S= F$ and $T = G$, then the two curves arose by splitting a larger one, and this larger one has control points $A$, $P$, $R$, $G$.
Of course, in floating point arithmetic, it's not likely that $S= F$ and $T = G$ exactly, so you'll need to use an equality tolerance. But this tolerance should be easy to choose because it's directly related to the geometry of the curves.
The computations might remind you of the de Casteljau algorithm. In fact, what we're doing here is running the de Casteljau algorithm to extend the curve on the left, and then we just check that the extension matches the curve on the right.