Using a CANVAS, I allow a user to draw a line. To show the direction, I would draw an arrow head to the end of the line. The line is drawn with a series of variable x,y coordinates, If I decide the arrow head direction using the last two points, I would sometimes get a good looking arrow head showing the overall direction of the line drawn by user. But if the user inflected drastically between the 2nd to the last point and last point the arrow gets distorted or point to the non overall trend / direction of the line. Can you point me to an algorithm on how to get the best direction of arrow head given a series of points.
Usually the NG part happens when the user hesitates drawing the line at the end part.