[metapost] Metafun : is "atan" the arctangent function?

Franck Pastor franck.pastor at me.com
Sun Jan 12 20:04:15 CET 2014


Le 12 janv. 2014 à 18:25, Dirk Laurie a écrit :

> 2014/1/12 John Kitzmiller <jkitzm at gmail.com>:
> 
>> atan is vardef'd in mp-tool.mpiv as: x = x-(x**3)/3+(x**5)/5-(x**7)/7 ,
>> part of the infinite series form. Maybe better to use asin(a/sqrt(a**2+1))?
> 
> Or use the builtin `angle`.
> 
> $ mf null
> This is METAFONT, Version 2.718281 (TeX Live 2012)
> (/usr1/local/texlive/2012/texmf-dist/metafont/base/null.mf)
> 
> * Pi=3.141592653589793;
> 
> * vardef atan(expr t) = angle(1,t)*Pi/180 enddef;
> 
> * show atan(1);
>>> 0.7854

I had a look in grafbase.mp, the file that contains the MetaPost macros for the mfpic package. It also defines an atan function this way:

vardef atan primary X =  angle (1, X)  enddef;

There is also an "invtan" function that gives the result in radians:

vardef invtan primary X =  radians (atan X)  enddef;

where the radians function is

vardef radians (expr t) =  t/radian  enddef;

and

radian := 57.29578;

is a rounding of 180/pi.

> http://tug.org/metapost/






More information about the metapost mailing list