Spline Tangents Part III

Once again, there were a few questions regarding this post; namely, how to draw the normal vector to the spline.  One person suggested using the fact that slopes of perpendicular lines are negative reciprocals.  Since we already know the slope of the tangent line, we know the slope of the normal line (although there are numerical issues with near or exactly vertical tangents).

That’s a good suggestion for a starting point.  An alternative is to use the fact that we have unit vectors in the tangent direction both ‘away’ and ‘toward’ the direction the curve moves with increasing parameter value.  The 2D rotation matrix corresponding to rotations of +/- PI/2 is particularly simple. We can rotate the already computed unit vectors and then determine a point along the normal the same distance as along the tangent line.  This is illustrated below,

Normal to a spline
Normal to a spline

The issue here is that the normal will flip when passing through a parameter value corresponding to a vertical tangent.  The reason is a subject for another post at another time. You are welcome to download the updated code from the Downloads section and experiment with both approaches. In the mean time, I’m hoping that the demo that created this series in the first place will be completed by the weekend or early next week.

Advertisement