I have come across a puzzling issue when using arctan2 in Numpy. Searching for atan2 errors did not answer the question, but someone might know the reason for this.
f = np.arange(0,100)
w = 2*np.pi*f/50
x = np.arctan2(sin(-w*d/2)*cos(w*d/2), cos(w*d/2)*cos(w*d/2))
gives different results to
f = np.arange(0,100)
w = 2*np.pi*f/50
x = np.arctan2(sin(-w*d/2), cos(w*d/2))
The former is out by an offset of $pi$ every period. Looks like a numeric issue but I have not seen any notes on this particular case.
atan2( y, x) gives the angle between the x axis and the vector x,y. Therefore atan2( y, x) and atan2( ay, ax) are the same if and only if a>0. For example atan2( y, x) is pi/4 but atan2( -1*y, -1*x) is -3pi/4.
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