[NTG-context] atan2 function

Alan Braslau alan.braslau at icloud.com
Fri Oct 14 16:40:01 CEST 2022

On Fri, 14 Oct 2022 10:07:19 +0200
Hans Hagen via ntg-context <ntg-context at ntg.nl> wrote:

> So you suggest to add atantwo? As side note, you can redure your 
> definition to:
>      vardef atantwo(expr dy, dx) =
>          if dx == 0 :
>              if dy < 0 : - fi pi / 2
>          else :
>              atan(dy/dx) if dx > 0 : if dy < 0 : - else : + fi pi fi
>          fi
>      enddef ;
> going further makes us end up in an one-line obscurity

An absurdity, as further discussion on this thread has shown:
atan is derived from angle, which is essentially atan2.
There is no need to circle around.

As a side point, I now use MP doubleprecision mode by default, although
I do believe that it is still preferable to use classic scaled integer
mode (and minifun) for text graphical embellishments. The only
practical point to consider when using doubleprecision mode for me is
the need to explicitly use format with "decimal i" to round the text
rendering of numbers.


More information about the ntg-context mailing list