when you dot product two vectors you get a scalar value. Generally it is very useful to find the projection of one vector on another.
The value of the dot product is like you mention, the multiplication of the magnitudes and the cosine of the angle between them:
dot = |a| |b| cos(theta)
(i.e. the projection of vector A on vector B, multiplied by the magnitude of vector B. Or vice versa, same thing).
You can also calculate the same value very quickly by summing the multiplication of the corresponding vector components:
dot = ax * bx + ay * by = |a| |b| cos(theta)
(There is no sqrt in calculating the dot product).
The usefulness comes in that you can use the second very quick method to calculate the dot product, and then calculate the angle between the two vectors:
dot = ax * bx + ay * by;
theta = acos(dot / (|a| |b|);
but most of the time you don’t even need to do that (acos, sqrt are all slow).
You can simply check if the dot is bigger or smaller than zero, and that will tell you if the angle is smaller or greater than 90 degrees (i.e. they are roughly in the same direction or not):
float dot = ax * bx + ay * by;
if(dot<0) printf("angle is > 90);
else if(dot>0) printf("angle is <90);
else printf("angle is 90");
So by dotting the adjacent segments you can tell if the curvature changes from >90 to <90. if you need more information, you can divide by the length of the segments to calculate the actual angle. But most of the times you can avoid that and just use the >0 check.
hope that helps!
EDIT:
If you’re going to be doing stuff like this on a contour, you’ll get better results if you blur the contour (the contour points, not the image) first (i.e. run lowpass filter). I’m sure there is a sample of this somewhere on the forum, I think theo posted it I think.