\chapter{Constraints and endpoint conditions}
\label{constraints}

So far, we've examined interior points in the spline. For a closed
curve, all points are interior, but open-ended curves are also of
interest. In addition, many shapes (such as letters in most fonts)
contain sharp corners, which are not well served by a pure
interpolating spline. In this chapter, we explore several choices for
the treatment of endpoints, and propose an alphabet of constraint
types for control points useful for making complex shapes.

\section{Natural elastica end conditions}

In the standard formulation of the elastica or Minimum Energy Curve
(MEC), an infinitesimally small strip threads the control points in
order, allowed to slide and pivot with no friction. Under such
constraints, the curvature at the endpoints naturally converges to
zero. Forsythe and Lee, in their variational study of the
elastica\cite{ForsytheLee}, explain that the curvatures of the two
points have separate Lagrange multipliers, uncoupled from the rest of
the system, so when the variation is zero (as in the minimum energy
solution), the curvatures are zero as well.

Similarly, the ``natural'' cubic spline is one in which the second
derivative of the endpoints, and thus the curvature, is zero. The
similarity is not surprising, as the cubic spline closely approximates
the MEC for small angles.

However, many target shapes have nonzero curvature at the endpoints.
Using a pure MEC or natural cubic spline, there is no way to closely
approximate the target curve. In particular, for a control polygon
consisting of points lying on a circular arc, the result will not be a
perfect circular arc. A good example is the letter `c' from a
geometric sans-serif font such as Futura. *** Figure ***

Indeed, the failure to achieve a circular arc is one of the
justifications for preferring the Minimum Variation Curve (MVC) over
the pure elastica. A circular arc, just as for a closed circle, has
constant curvature and thus zero variation. Thus, it clearly satisfies
the minimum variation condition.

While constraining zero curvature at the endpoints may well be
``natural,'' it is by no means the only choice of end constraints. In
drawing letters for fonts, curve endpoints with nonzero curvature
outnumber those with zero curvature. For a two-parameter spline,
another reasonable choice is to constrain the segment between and
endpoint and its immediate neighbor to be a circular arc. This
constraint is enforced exactly in C-splines\cite{DBLP:journals/cad/SequinLY05}, and to a
close approximation in Hobby's splines\cite{Hobby85}.

In terms of curvature and curvature derivatives, the ``natural''
endpoint constraint is $\kappa = 0$, while constraining $\kappa' = 0$
will result in a circular arc (at least for round splines such as the Cornu
spiral). The number of constraints is the same, and in practice such
constraints are not at all difficult to solve.

In general, the total number of constraints must be equal to the total
number of parameters. Continuity constraints can be counted as one
half of a constraint on each endpoint. Thus, a knot with G2 continuity
counts as one constraint on each side. For the simple case of an open
curve with G2 knots, that means one additional constraint is needed at
each endpoint. For an open curve with G4 knots, two additional
constraints are left over. In this case, the natural constraints,
closely resembling MVC behavior, are for the first two derivatives of
curvature to be zero.

\section{Mixing G2 and G4 knots}

A Cornu spiral's curvature is a linear function of arclength, and thus
it is a special case of a third-order polynomial spiral. The G2
continuity constraints account for two parameters per segment, leaving
two left over. The second derivative of a straight line is zero, so we
can simply set $\kappa'' = 0$ for both endpoints.

Thus, we can treat both G4 and G2 (Cornu spiral) splines as instances
of the more general four-parameter polynomial spline family with
additional constraints providing more expressiveness. Further, it is
possible to mix G2 and G4 knots within the same spline, as shown for
example in Figures \ref{g2-g4-mix} and \ref{ecc}. The G2 curvature
peaks at the narrow ends more closely approximates the curvature
profile of an ellipse, and, by allowing a broad region of low
curvature at the wide ends, allows a higher eccentricity before
inflections appear.

\begin{figure*}
\begin{center}
\includegraphics[scale=.5]{figs/ecc0}
\includegraphics[scale=.5]{figs/ecc1}
\caption{\label{ecc0}Maximally eccentric oval with G2 and G4 constraints.}
\end{center}
\end{figure*}

\begin{figure*}
\begin{center}
\label{g2-g4-mix}
\includegraphics[scale=.5]{figs/ecc2}
\caption{\label{ecc2}Maximally eccentric oval with mixed constraints.}
\end{center}
\end{figure*}

\begin{figure*}
\begin{center}
\label{ecc}
a)\includegraphics[scale=.5]{figs/ecc0}
b)\includegraphics[scale=.5]{figs/ecc3}\\
c)\includegraphics[scale=.5]{figs/ecc4}
d)\includegraphics[scale=.5]{figs/ell0}
\caption{\label{ecc3}Eccentricity 0.56199 oval with constraints: (a)
  G2, (b) G4, (c) mixed (d) ellipse.}
\end{center}
\end{figure*}
