Now, some actual application of what I learned in calculus 3. The previous demo was on curve fitting algebraic curves. Now that this is done, it's time to add the tangent, normal, and curvature circle. To start, we will need the tangent line of this function. Note that the function is now two functions, one for the x-coordinate, and one of the y-coordinate. This can be expressed using a vector function, f( t ) = ( X( t ), Y( t ) ). To get the tangent line, we still need a rise over run based on the derivative at some point a. Well, the rise is based solely on Y( t ), and the run solely on X( t ). So the resulting slope then becomes Y '( a ) / X '( a ). The tangent line function itself is y = [ Y '( a ) / X '( a ) ][ x - X( a ) ] + Y( a ). The normal line is again just a 90-degree rotation of the tangent line, easily obtained by taking the negative inverse of the slope. The curvature now requires both the x and y components of the function, and the full function is κ( t ) = [ X '( t ) Y ''( t ) - Y '( t ) X ''( t ) ] / [ X '( t )2 + Y '( t )2 ]2/3. It looks a little messy, but the reality is the function just involves the first and second derivatives—it's not that bad.
The scroll bar selects the location to place the tangent line, normal, and curvature circle. Since the curve is no longer a function and can double back on itself, I could no longer use the floating bar above the image. If you adjust the curve, you may notice the curvature circle is sometimes on the outside of the function, looping in the wrong direction. This is one irritating item I've been trying to fix. It seems from the fact the normal does not always point inward, and I have thus far been unsuccessful in figuring out how to make this happen. It does, however, give me something else to work on.