[metapost] turningnumber revisited

Hartmut Henkel hartmut_henkel at gmx.de
Thu Jul 7 23:21:52 CEST 2011


On Thu, 7 Jul 2011, laurent at math.toronto.edu wrote:

>      A key example of bezier path that may appear as
> segment of  a  p \in \C+ and not in \C is:
>
>  \b(A,B,C,D) with Casteljau polygon
>
>             A=B --- C
>                      \
>                       \
>                        D
>
> The derivative vector at the point A=B is zero but
> the direction vector there is the non-null direction
>  (C-A) / |C-A|  .
>
>      The good news of today is that the turning
> number calculation algorithm I gave for \C on Tue, 28
> Jun 2011 02:40:50 -0400 (EDT) obviously applies to
> \C+.
>
>      Unfortunately, instabilities of turning number
> occur in \C+.  For example, the point A=B of the above
> example is a cusp of its maximally extended cubic
> path, and that path can devellop a loop under
> perturbation. Thus *practical* problems for winding
> number calculations remain for paths in \C+.

Can't one be happy that points A=B are _identical_ as any kind of
transform will give at least the same new A'=B' position also
numerically?

Seems turningnumber is difficult particularly on the numerical side. E.
g., given this harmless example:

prologues := 3;
beginfig(1)
u = 50mm;
pair a, b, c, d; path p;
a := origin; b = (0.7u, 1u); d = up * 1u;
for i = 0 step 0.03 until 1:
  c := i[a,b];
  p := a -- b -- c -- d -- cycle;
  draw p;
  show(i, turningnumber(p));
endfor;
endfig
end

It shows that even c is not always on the straight line through a and b!
Simply as it ratchets along the numerical staircase between a and b so
that a--b and c--b are not always parallel, and so there can be even a
loop/triangle c -- (exact i[a,b]) -- b -- cycle. And not even Beziers
are involved. How can such cases be tackled?

Regards, Hartmut


More information about the metapost mailing list