Hi there,
How is atan2 called? I rolled my own as follows:
% SOT
\startuseMPgraphic{HexGridBaseGraphic}
vardef atantwo( expr ax, ay, bx, by ) =
save theta;
numeric dx;
numeric dy;
numeric theta;
dx := bx - ax;
dy := by - ay;
theta := 0;
if (dx > 0):
theta := atan( dy / dx );
elseif (dx < 0) and (dy >= 0):
theta := atan( dy / dx ) + pi;
elseif (dx < 0) and (dy < 0):
theta := atan( dy / dx ) - pi;
elseif (dx == 0) and (dy > 0):
theta := pi / 2;
elseif (dx == 0) and (dy < 0):
theta := -pi / 2;
fi;
%theta := atan( dy, dx );
theta
enddef;
% EOT
When this runs, the expected result is generated:
https://pdfhost.io/v/xdNxANU18_scaled
When uncommenting "atan( dy, dx )", an unexpected result is generated:
https://pdfhost.io/v/QdfU89IL._scaled
Is atan with two parameters supposed to behave like atan2?
Cheers!
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________