# [metapost] turning number -- the neverending story?

Boguslaw Jackowski B_Jackowski at GUST.org.pl
Mon Jan 9 11:52:52 CET 2012

```Dan, thank you very much for the detailed analysis of the case,
hope it will be helpful for Taco.

Nevertheless:

Dan:
> If metapost is using the algorithm discussed on this list,

I believe that the situation is ripe to replace the current
version of the turning number algorithm with a new one, written
from scratch. (Of course, I can ofer my help, if anyone needs it.)

Implementing the winding number (discussed minutely on this list)
and next implementing the turning number as the winding number
of the unit tangent vector around the origin should work --
for smooth curves, with non-vanishing derivative.

[As far as I remember, this was also the suggestion
of Larry Siebenmann; I have an impression that a variant
of this approach is implemented in MF, and thus in MP,
although I was not able to analyse it carefully enough,
given free time I was given :) ]

The only problem is -- as Dan some time ago rightly emphasized --
how to proceed with the singular cases? One must use ad hoc
solutions -- this is obvious -- but how to guarantee (at
the level of mathematical exactness) the consistence?

Dan, are you able to sketch guidelines for handling singular cases?
It seems to me that you have the subject carefully thought over.
Or, maybe, you know papers concerning this subject?

BJ
>The only peculiarity of the path is that the precontrols and
>postcontrols coincide (i.e., it is actually a so called b-spline).

Dan
> I doubt this peculiarity has anything to do with this problem.

Hmmm... Why, then, if you move randomly all nodes of the
curve from my example, e.g.,

i:=0; z0=origin;
for f:=0, 1, 2, 2, -1, -1, 0, 0:
i:=i+1; z[i]=z[i-1] +
(uniformdeviate 100, uniformdeviate 100) +
p rotated (f*a);
endfor

the turning number still reamins equal to 0?

Cheers -- Jacko

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Bogus\l{}aw Jackowski: B_Jackowski at GUST.ORG.PL
----------------------------------------------------------------
Hofstadter's Law: It always takes longer than you expect, even
when you take into account Hofstadter's Law.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

```