next up previous
Next: dd_splines Up: dd_splines Previous: dd_splines

2. Gluing two Bézier curves

First attempt: Matching endpoints

Let us start with two Bézier curves that can be glued together but otherwise are not well matched. Let the first curve have control points $ P_0 $, $ P_1 $, $ P_2 $, $ P_3 $ and let the second curve have control points $ Q_0 $, $ Q_1 $, $ Q_2 $, $ Q_3 $, as shown in Figure [*]. Suppose that $ P_3 = Q_0 $. For convenience let this point of joining also be called $ S $; i.e., $ S = P_3 = Q_0 $. The result is shown in Figure [*].

Figure: A coarse gluing

\begin{picture}(345,129)
\put(0,0){\includegraphics{\epsfile }}
\put(0,10){\make...
...(280,129){\makebox(0,0){$Q_2$}}
\put(345,64){\makebox(0,0){$Q_3$}}
\end{picture}

The curve has a corner, because at $ S $ the first Bézier curve has first derivative $ 3(S - P_2) $ and the other has first derivative $ 3(Q_1 - S) $, but the vectors $ S - P_2 $ and $ Q_1 - S $ do not even have the same direction. (Recall that subtracting one point from another, say $ A-B $, gives the vector from $ B $ to $ A $.)



Second attempt: Matching values and first derivatives

A much better join is obtained if we require that $ S-P_2 = Q_1 - S $, or equivalently, that $ S $ be the midpoint of the line segment $ \overline {P_2 Q_1}$, so that the first derivatives match at the point of gluing. Figure [*] shows an example where this condition is met.

Figure: A better gluing, matching first derivatives

\begin{picture}(345,129)
\put(0,0){\includegraphics{\epsfile }}
\put(0,64){\make...
...ut(280,0){\makebox(0,0){$Q_2$}}
\put(345,64){\makebox(0,0){$Q_3$}}
\end{picture}



This example certainly looks smoother. However, it is still not ideal. Imagine taking a fast train ride along a track of this shape. On the first Bézier segment you are curving so that you are pushed against the left wall of the train; on the other you are curving the other way and are pushed against the right wall. At the point of joining you are jerked from one side of the train to the other. For an even smoother join, then, the curvature should be continuous. Because the curvature can be expressed in terms of the first and second derivatives, continuity of curvature can be achieved by matching second derivatives, as well as first derivatives, at the point of gluing.



Third attempt: Matching values, first derivatives, and second derivatives

Recall that at $ S $, where $ t = 1 $ for the first Bézier curve and $ t = 0 $ for the other, the second derivatives of the Bézier curves are respectively $ 6(P_1 - 2
P_2 + S) $ and $ 6(S - 2 Q_1 + Q_2) $. Thus we want

$ 6(P_1 - 2 P_2 + S) = 6(S - 2 Q_1 + Q_2) $, or equivalently, $ P_1 - 2 P_2 $ $ = $ $ Q_2 - 2 Q_1 $.

Here is an interesting way of interpreting this equation. Negate both sides to get $ 2 P_2 - P_1 = 2 Q_1 - Q_2 $. The motivation for doing this is that both sides now have coefficients summing to 1 and so should represent points, independently of coordinatization.

The left-hand side corresponds to a particular point $ A_+ $ on the line through $ P_1 $ and $ P_2 $. In fact, $ A_+ $ $ = $ $ 2 P_2 - P_1 $ $ = $ $ P_2 + 1 \cdot (P_2 - P_1) $, as shown in Figure [*]. Let us call $ A_+ $ the right apex of the first control polygon. Similarly, the right-hand side of the equation is the left apex $ A_- $ $ = $ $ 2
Q_1 - Q_2 $ of the second Bézier curve, as shown.

Figure: A gluing almost matching second derivatives

\begin{picture}(345,129)
\put(0,0){\includegraphics{\epsfile }}
\put(0,10){\make...
...162,129){\makebox(0,0){$A_+$}}
\put(205,129){\makebox(0,0){$A_-$}}
\end{picture}

As you see, in this example the two apexes are not equal, so the equation is not satisfied and the second derivatives at $ S $ of the two Bézier curves still do not match. Figure [*] shows an example where they do match, with both apexes being at a common point $ A $:

Figure: A gluing matching second derivatives

\begin{picture}(406,146)
\put(0,0){\includegraphics{\epsfile }}
\put(0,8){\makeb...
...put(406,8){\makebox(0,0){$Q_3$}}
\put(181,146){\makebox(0,0){$A$}}
\end{picture}

The relevant part of Figure [*] looks like the letter $ A $ or like an A-frame cabin.

Definition. An $ A-frame $ is a figure with points as indicated, in which $ S $ is the midpoint of $ \overline {P_2 Q_1}$, $ P_2 $ is the midpoint of $ \overline {P_1 A}$, and $ Q_1 $ is the midpoint of $ \overline {Q_2 A}$. An example is shown in Figure [*].

Figure: An A-frame

\begin{picture}(261,146)
\put(0,0){\includegraphics{\epsfile }}
\put(1,43){\make...
...\put(260,0){\makebox(0,0){$Q_2$}}
\put(87,146){\makebox(0,0){$A$}}
\end{picture}

Thus we see:

Observation. If two Bézier curves are joined at a point $ S $, both their first and second derivatives match at $ S $ if and only if their control polygons fit an A-frame.



Note: Matching third derivatives as well sounds promising, but is not helpful, as it forces both curves to be parts of just one third-degree curve. Thus the flexibility obtained by gluing curves is lost. See the Exercises.




next up previous
Next: dd_splines Up: dd_splines Previous: dd_splines
Kirby A. Baker 2002-03-01