[metapost] Re: d\'ej\`a vu or turningnumber, area et caetera

Daniel H. Luecking luecking at uark.edu
Sat Feb 5 23:31:55 CET 2005


On Fri, 4 Feb 2005, Daniel H. Luecking wrote:

> Mfpic's grafbase.mf (version 0.7) has postdirection and predirection.
> It is used to determine the orientation of arrowheads at the end of
> paths. Version 0.8 (coming Real Soon Now) uses a different approach, but
> now uses these to create parallel paths.  The code follows.
>
> % Note: "post[n](f)" = "postcontrol n of f", etc. Also, the time is
> % not expected to be integral, and if a trivial segment (all
> % four controls coinciding) occurs, the next segment is examined.
>
[snipped]
> vardef __dir (expr p) =
>   save v, w; pair v, w; w := pnt0 (p);
>   v := origin;
>   for n = 1 upto length (p) :
>     v := post[n-1] (p) - w; exitif v <> origin;
>     v := pre [ n ] (p) - w; exitif v <> origin;
>     v := pnt [ n ] (p) - w; exitif v <> origin;
>   endfor
>   v if v<>(0,0): /abs(v) fi
> enddef;
>
> vardef trivial primary p = __dir (p) = origin enddef;

I just had occasion to run a test on mfpic and the "trivial"
command, intended to return a boolean, failed. The = sign is
apparently not taken to be a boolean operation, even though it occurs
in and "if ... :" construction. MF/MP report an inconsistent equation.
Inserting parentheses around the expression cured that:

vardef trivial primary p = (__dir (p) = origin) enddef;


Dan

-- 
Dan Luecking
Dept. of Mathematical Sciences
University of Arkansas
Fayetteville, AR 72101



More information about the metapost mailing list