[metapost] turningnumber revisited
Dan Luecking
luecking at uark.edu
Wed Jun 1 05:48:36 CEST 2011
At 12:19 PM 5/31/2011, Dan Luecking wrote:
>At 04:30 AM 5/31/2011, Boguslaw Jackowski wrote:
>
>>Dear colleagues,
>>
>>I was nearly sure that the problem of turningnumber has
>>gone forever... Alas, the simple example below shows that the
>>implementation of the turningnumber primitive needs fixing:
>>
>>%%%% BEGIN turnpath.mp
>>path p;
>>p=origin .. controls (100,200) and (300,500) ..
>> (0,500) .. controls (-300,500) and (-100,200) ..
>> origin & cycle;
>>for i:=0 upto 8: show turningnumber(p rotated 45i); endfor
>>end.
>>%%%% END turnpath.mp
>>
>>A 2-node, 4-control path above should have the turningnumber=1.
>>And this is the case with MF; with MP, however, the result depends
>>on the rotation of the path.
>>
>>MP 1.211 and MP 1.503 produce the result
>>
>> >> -1
>> >> -1
>> >> -1
>> >> 1
>> >> 1
>> >> 1
>> >> 1
>> >> -1
>> >> -1
[random thoughts, likely incorrect, omitted]
>Some testing (same path, many minute changes in angle) shows that
>one gets -1 when the starting direction has angle A in range
>0 < A <= 180 and +1 otherwise.
On second thought, further testing show such consistency
(when the sign is wrong, the starting angle is in (0,180])
that this feels more like a simple bug that somehow imposes
an incorrect sign in just that case, perhaps its even just a typo.
I note that polygonal paths don't seem to have a problem.
Dan
Daniel H. Luecking
Department of Mathematical Sciences
Fayetteville, Arkansas
http://www-cs-faculty.stanford.edu/~knuth/iaq.html
More information about the metapost
mailing list