I don't think an atantwo is needed. I *thought* I had read somewhere that atan( y, x ) was equivalent to calling atan2 in Lua. Ensuring there's no breakage when x == y would be nice, though. It was a little surprising to see angle return degrees rather than radians, but it does simplify my code:
dc := vbc - vac; dr := vbr - var; vi := 0; if not( dc == dr ): vi := round( angle( dc, dr ) / 60 ); fi; % Compute the direction towards the first segment (to vertex of an edge). vangle := vi * 60 * pi / 180; Even simpler would be: dc := vbc - vac; dr := vbr - var; vi := round( angle( dc, dr ) / 60 ); % returns 0 when dc == dr % Compute the direction towards the first segment (to vertex of an edge). vangle := vi * 60 * pi / 180; Or accepting a third argument as the return value in the special case: vi := round( angle( dc, dr, 0 ) / 60 ); % returns 0 when dc == dr Cheers! ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / 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 ___________________________________________________________________________________