
On 16-10-12 20:24, Johan Engelen wrote:
On 16-10-2012 13:43, Jasper van de Gronde wrote:
...
It is possible to make segments with and without a zero-length handle that look exactly the same.
It should not be, in general. (Fewer degrees of freedom.)
I meant: zero-length handle segment ---> non-zero length handles segment. That goes in the direction of increasing degrees of freedom, so at least no worries for that matter. But perhaps it is indeed mathematically impossible. See attachment.
Now I get it. Yes, but... (see below).
Also (just as an observation), as the handle gets smaller, its influence decreases. So although locally you have a very large curvature, it's only over a very small portion of the curve.
Does that mean that as the handle goes to zero, it's region of influence tends to zero too and hence perhaps it is not very indicative of the visual curvature any more?
Exactly right.
Wouldn't l'Hopital imply that you can get away by using +1 higher derivs instead?
You're completely right. (If you intended taking the derivative of the numerator and denominator and dividing those.) However, higher derivatives can (and will) still be zero in this case, so this complicates things a bit.
(simply do the same "trick" again in those cases? ;)
Yes, you can do that, but that's basically a pretty convoluted way of doing the same thing as what I did in a slightly different way. Basically what happens is that the denominator typically stays zero for "longer" then the numerator, unless you have a completely straight line (segment).
However, if you make the first handle zero-length, and then compute the limit of the curvature as t goes to zero, then you find that the curvature is equal to det([P3-P1,P4-P1]) divided by something that is zero at t=0 and positive for t slightly above zero, as long as P3-P1 is not zero-length. Thus, if det([P3-P1,P4-P1])=0, (all points and handles on a line), then the curvature at t=0 is zero, and otherwise it is infinite with the sign of det([P3-P1,P4-P1]).
So, I stand corrected, the rule isn't zero-length=zero-curvature, but rather, a zero-length P1-P0 implies that the curvature at P0 is either -infinity, zero or +infinity, depending on the sign of det([P3-P1,P4-P1])=0. (Assuming at least some point does not coincide with P1.)
I have an example attached where there are two paths: one with zero-length handle, and one 'normal' path. They are visually *very* similar; if you zoom in you will notice a small difference in angle and the end of the path on the right-hand side. I think the normal path has a non-zero curvature (it is not straight at the end), so I thought the zero-length path would have the same curvature.
Now there are two different viewpoints to a solution:
- math. SVG definition
- user
Don't know which one to take...
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.