My formula f=arctan(ImZ/ReZ)
There are two options:
Option 1 (atan):
ImZ=-4.593172163003 ImR=-4.297336384845 >>> z=y/x >>> f1=math.atan(z) >>> f1 0.8186613519278327
Option 2 (atan2)
>>> f=math.atan2(y,x) >>> f -2.3229313016619604
Why are these two results different?
atan is used if we only know or are interested in y/x not y and x individually. So if p = y/x then to get α we'd use atan(p) . You cannot use atan2 to determine the quadrant, you can use atan2 only if you already know which quadrant your in!
The atan2() function, as its name suggests, is utilized to calculate and return the value of the arc tangent of y/x in terms of radians in Python. The atan() function has the same math library functions with atan2() .
The four-quadrant inverse tangent, atan2(Y,X) , returns values in the closed interval [-pi,pi] based on the values of Y and X , as shown in the graphic. In contrast, atan(Y/X) returns results that are limited to the interval [-pi/2,pi/2] , shown on the right side of the diagram.
It's because atan2, along with all the other inverse trigonometric functions, is incredibly slow.
Atan takes single argument and Atan2 takes two arguments.The purpose of using two arguments instead of one is to gather information on the signs of the inputs in order to return the appropriate quadrant of the computed angle, which is not possible for the single-argument Atan
Atan2 result is always between -pi and pi.
Reference: https://en.wikipedia.org/wiki/Atan2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With