## Quadratic Hermite Curves Part 5

Part four of this series illustrated how to join two quadratic Hermite curves with C-1 continuity at the join. This part examines the mathematical foundation of creating a spline that interpolates an arbitrary number of knots using quadratic Hermite segments.

To begin, review the two-segment case that interpolates three points, P_{0}, P_{1}, and P_{2}. The start tangent vector for the first segment is T_{0} and the start tangent for the second segment is T_{1}. Both tangents are functions of t. T_{0} is shorthand notation for the tangent at t=0 for the first segment. T_{1} refers to the tangent at t=0 for the second segment. T_{0}(1) refers to the end tangent of the first Hermite segment. T_{1}(1) refers to the end tangent for the second segment. It is necessary to introduce superscripts and subscripts into the notation at this time.

The boundary condition at the join (P_{1}) is that T_{0}(1) = T_{1}. Recall from part 2 of this series that T_{0}(1) = 2(P_{1} – P_{0}) – T_{0}, so T_{1} = 2(P_{1} – P_{0}) – T_{0} or T_{0} + T_{1} = 2(P_{1} – P_{0}). Note that T_{1} can not be computed until T_{0} is fixed. If another segment is added, there is a similar boundary condition for T_{2} in terms of T_{1}(1). You can show that that the vector of tangents is represented by the equation AT = b, where

A = | 1 1 0 0 0 ... 0 | | 0 1 1 0 0 ... 0 | | . . . | | 0 0 0 0 ... 1 1 | T = [ T_{0}T_{1}... T_{n-1}]^{t}b = 2[P_{1}-P_{0}P_{2}-P_{1}... P_{n-1}-P_{n-2}]^{t}

For n data points, A is n-1 x n. The system of equations is underdetermined as expected since the choice of initial start tangent is arbitrary. Once this value is fixed, the system of equations can be easily solved. With T_{0} fixed, there are n-1 tangents to be computed. The first row of A yields one equation in one unknown, T_{1}. Once T_{1} is computed, the second row yields an equation for T_{2} in terms of T1. Solving the complete system is a generalization of the approach in part four of this series.

To draw the spline it is not strictly necessary to compute the last tangent, although it is handy to have in the case that new knots are added onto the spline.

Notice that the polynomial coefficients are not directly part of the solution. They follow once the start tangents are set for each segment. It is possible to create a matrix equation for the coefficients, but that requires more effort and we already have software that automatically computes the coefficients once the start tangents are provided.

Although it’s nice to see how the theory all ‘fits together,’ I know you want to see some code, so the final part of this series will introduce a quadratic (interpolative) spline in Degrafa 🙂

## Quadratic Hermite Curves Part 4

Part 3 of this series introduced a method to draw the tangent segment to the quadratic Hermite curve at a fixed length at any parameter value. This was contrasted to the geometric interpretation of the end tangent to the first segment.

By directly computing the end tangent using the methodology in part 2, we have a vector that can be used as an initial tangent for a second Hermite curve with a common join point at P1. What is the maximum continuity that could be achieved at the join? The derivative of a quadratic curve is linear in t (first-degree polynomial) so the second derivative is a constant, namely 2c in terms of the polynomial coefficients.

Recall from part 1 that c = P1 – P0 – T1 for the first curve (where T1 is the start tangent for the first segment). If the join point is P1 and the second curve interpolates some point P2, then its corresponding coefficient is P2 – P1 – T2. The second derivatives can only be equal if P1 – P0 – T1 = P2 – P1 – T2 or 2P1 = P0 + P2 + (T1-T2).

In general, only C-1 continuity can be achieved.

This continuity is easy to achieve based on the simplicity of the curve construction. The end tangent for the first curve is used to set the start tangent for the second curve. This is illustrated in following screenshot.

To experiment with the demo, the first Hermite curve is drawn as in prior demos. A crosshair appears in the drawing area. Click to define the P2 point and the second segment is drawn. You may study the code to see the algorithm in action.

In the next part of this series, we will look at extending this method to an aribtrary number of interpolation points.