On Date: Wed, 17 Oct 2012 09:53:59 +0200
Jasper van de Gronde wrote:
Now there's the real problem. I even asked a question related to this on
math.stackexchange, as it was driving me crazy. Essentially the problem
is that curves with zero-length handles do tend to have infinite
curvature at the endpoint(s) with a zero-length handle, but the
curvature grows very quickly over a very short length of the segment. So
visually, you hardly see anything. Put differently, the slope has a
non-zero derivative at the endpoint, while the norm of the derivative is
zero, so the slope changes by some finite amount over an infinitesimally
small length, leading to infinite curvature, but a finite (and typically
quite small) change in slope.

So essentially you have the extremely weird situation where a slope that
looks very smooth and (almost) straight, can actually have infinite
curvature at its endpoints (I think in principle this can also happen
elsewhere, but that's less of a problem in this context).

The problem with taking an approximation of the path is that I'm not
entirely sure how "stable" this is. So would taking a slightly different
approximation give you a completely different curvature, or is there
some "natural" curvature that can be defined? In fact, I've just tried
fitting a quadratic curve through the first 1/3 of a B?zier curve with a
zero-length handle (at the first node), and I can get a huge range of
curvatures, without a big difference in fitting quality.

Of course this can always be "solved" by simply prescribing an
approximation method. One thing you could try is to basically take a
finite difference approximation to the curvature over a predefined range
of the curve (if the SVG spec would do something like this, the range
would probably have to be specified in the spec). For example, take the
angle of the curve at t=0 and t=1/3, take the difference and divide by
the arc-length. You could experiment with the range, or even try to do a
"higher order" approximation. I'm not entirely sure what this would
accomplish though.

I've not read the full conversation but in Synfig, when it is needed to evaluate
the tangent (and by perpendicularity the normal) at the start or end point of a bezier
with a tangent small than a certain small length (zero-length tangent condition) we don't
evaluate the derivative of the bezier exactly on the start or end of the bezier but in a fixed
small earlier or later bezier index. We use 0.025 as that value.

See CUPS_TANGENT_ADJUST usage in the code for the outline layer:
https://github.com/synfig/synfig/blob/master/synfig-core/src/modules/mod_geometry/outline.cpp

It works reasonably well in most of the cases.
I hope it helps.
Cheers
Carlos