[metapost] turningnumber bug?

Karel Horák akk64 at quick.cz
Sat Jul 7 04:18:57 CEST 2007


I have the same experience when compiling some metatype2 programs with 
the last version of metapost :-[

Karel Horak


Dan Luecking napsal(a):
> Dear MetaPosters:
>
> I wonder if a few of you would try the following code and tell
> me what you get. My MetaPost (TeXLive2007) claims this version:
>    This is MetaPost, Version 1.000 (Web2C 7.5.5) (mem=mpost 2007.6.26)
>
> I checked the bug tracker at foundry.supelec.fr/projects/metapost/
> without finding any mention of a possible bug.
>
> Here is the code:
>   path P;
>   message "";
>   P := (4,-0.00012) -- (-16,49) -- (17,32)
>        --(17.0,0)..controls (13.0,0) and (9,0)..cycle;
>   % shows -2 and a warning:
>   show turningnumber P;
>
>   P:=reverse P;
>   % shows 1:
>   show turningnumber P;
>
>   % make a tiny change in point 0:
>   P := (4,0.000) -- (-16,49) -- (17,32)
>        --(17.0,0)..controls (13.0,0) and (9,0)..cycle;
>   % correctly shows -1:
>   show turningnumber P;
> end.
>
> Here is the rest of the log:
> (test.mp
> Warning: The turningnumber algorithms do not agree. The current 
> computed value is -2, but the 'connect-the-dots' algorithm returned -1
>  >> -2
>  >> 1
>  >> -1 )
>
> I can pin the problem down to the last segment of the path:
>
> The algorithm (as I understood it when we discussed it here)
> should show that there are no changes in the curvature of
> this last segment, and that the curvature is positive (leftward
> turning). Thus, the change in angle along this segment should be
> the angular difference between the direction vector leaving (17,0)
> (which is (-1,0)) and the direction vector entering (4,-.00012)
> (which is about (-1, -0.00003)). That change is about .00175 degrees.
> I am guessing there is an incorrect calculation that subtracts
> angles:
>      -179.99825 - 180 = -359.99825
> instead of determining the actual amount of rotation.[*]
> This would account for the difference of -1 between the two
> turningnumber calculations.
>
> [*] Since the leftward turning implies a change in angle strictly
> between 0 and 360, the incorrect angle difference of -359.99825
> should be corrected by adding 360.
>
>
> Dan
>
>
> Daniel H. Luecking
> Department of Mathematical Sciences
> University of Arkansas
> "I reject your reality, and substitute my own" --Adam Savage
>
> --
> http://tug.org/mailman/listinfo/metapost
>
>   



More information about the metapost mailing list