Quad Hermite Curves Part 2
In the previous post, we saw how to construct a quadratic curve from two points and a start tangent. If the eventual goal is to join one or more of these segments, we need to know how to compute the end tangent. Note from the prior post that the curve’s derivative is P’(t) = b + 2ct, with b = T and c = P1 – P0 – T. From this, we have P'(t) = T + 2(P1 – P0 – T)t . The end tangent occurs at t = 1, so P'(1) = 2(P1-P0) – T. The geometric interpretation of this formula is illustrated in the following diagram.
The constituent elements of the formula are illustrated with dashed lines (courtesy of a Degrafa decorator). At first glance, it seems that the vector 2(P1-P0) – T is not at all tangent to the curve at P1. Recall that with Hermite curves, the tangents are typically described relative to a parent coordinate system. In the computations, the tangent is computed relative to the first interpolation point. The endpoint of 2(P1-P0) – T is used to create delta-x and delta-y values from P0. These deltas are added to P1 to draw the actual tangent vector, illustrated in red.
In the online demo, you may move either P0, P1, or T and see each element of the construction (without labels). The length of the tangent segment varies based on the deltas. As an exercise, try computing a unit vector in the direction of the tangent and draw it with constant length.
There is an issue with the dash line decorator in terms of altering the dash width and spacing. I did not write the decorator, so I’m not familiar with the internals. If time allows, I will look into it. In the mean time, study the code and in the next post of this series, we’ll look at the general tangent to the curve in more detail. After that, we will see how to join two quadratic Hermite segments with continuity at the join.