expr atan / cartopol
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?
-110
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.
aa
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 :)
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!