[metapost] problem with negative's angle ?

Franck Pastor franck.pastor at mac.com
Sat Mar 8 19:22:42 CET 2014


Le 8 mars 2014 à 18:17, Laurent Méhats a écrit :

> Le 08/03/2014 17:53, Laurent Méhats a écrit :
>> beginfig(3)
>>   draw cc;
>>   for i=0 upto h_num-1:
>>     label (decimal i, % ou (i + 1)
>>       point (directiontime (1, 0) rotated -(i/h_num*360) of cc) of cc);
>>       % point défini en fonction de la direction de cc
>>   endfor
>> endfig;
> 
> Après consultation (tardive ...) du manuel, on peut même simplifier en :
>  for i=0 upto h_num-1:
>    label (decimal i, % ou (i + 1)
>      directionpoint (1, 0) rotated -(i/h_num*360) of cc);
>  endfor


Yet another formulation, making use of the handy "along" operator:

input mp-tool.mpii;

beginfig(1);
  path cc;
  cc=reverse fullcircle rotated 90 scaled 3cm;
  draw cc;
  for i=0 upto 11:
    freelabel(decimal(i), point i*30/360 along cc, origin);
    endfor;
endfig;
end.

The "along" operator can be defined as (see the Metafun manual, p. 61):

primarydef pct along pat =
	(arctime (pct * (arclength pat)) of pat) of pat
enddef;

which is precisely the formulation used in Christophe's initial program.








More information about the metapost mailing list