expr atan / cartopol

    May 03 2010 | 2:27 pm
    guten morgen,
    i am trying to replace [cartopol] with [expr sqrt(($f1*$f1)+($f2*$f2))] and [expr atan($f2/$f1)]
    when the real input is negative and the imaginary input is 0 (i.e. no argument to cartopol) it should give pi, but it gives -0.
    wtf? did i use the atan function wrong somehow?

    • May 03 2010 | 3:08 pm
    • May 03 2010 | 3:16 pm
      if $f2 is 0, in principle atan has no way to know if $f1 is > or < 0.
      to achieve what you're looking for, you should either set up some conditions to manage signs and 0s, or use atan2 instead.
    • May 04 2010 | 4:47 am
      ok will try both .. i am not really sure what atan2() actually does ...
      managing signs ... i have no idea ... .. abs() wont help much to get the same output than from cartopol :)
    • May 04 2010 | 9:11 am
      I had to look up what atan2 actually does too...but that's awesome, never knew it was so common. That would have saved me some stupid ifs in Java as well. Works like a charm, thanks!