Log in

View Full Version : (FPGA) high throughput inverse tangent 2 input


Betty Boop
21-01-2012, 21:04
Hello! I would just like to ask what is the effect of having a 'negative x' on the high throughput inverse tangent (2 input)? It's because when I have 'negative y' (and 'positive x'), the answer is correct. However, whenever I have 'negative x' (regardless of the sign of y), the answer would always be wrong. Thank you for your time!

Ether
21-01-2012, 21:15
Hello! I would just like to ask what is the effect of having a 'negative x' on the high throughput inverse tangent (2 input)? It's because when I have 'negative y' (and 'positive x'), the answer is correct. However, whenever I have 'negative x' (regardless of the sign of y), the answer would always be wrong.

Please give a specific (numerical) example of 2 inputs which gave a wrong output. Give the three numbers X, Y, output.

Betty Boop
21-01-2012, 21:25
*The output is not yet multiplied to pi so that it is expressed in pi radians. :)

input: y = 1, x = 2
output: 0.1482 (correct)

input: y = -1, x = 2
output: -0.1482 (correct)

input: y = 1, x = -2
output: 0.8542 (even the sign is wrong)

input: y = -1, x=-2
output: -0.8518 (sign is again wrong and from my observation, it doesn't take into account the sign of x)

Ether
21-01-2012, 21:43
*The output is not yet multiplied to pi so that it is expressed in pi radians. :)

input: y = 1, x = 2
output: 0.1482 (correct)

input: y = -1, x = 2
output: -0.1482 (correct)

input: y = 1, x = -2
output: 0.8542 (even the sign is wrong)

input: y = -1, x=-2
output: -0.8518 (sign is again wrong and from my observation, it doesn't take into account the sign of x)

Those outputs are all correct. See attachment.

Starting from the +X axis and going counterclockwise, atan2 goes from 0 to +pi

Starting from the +X axis and going clockwise, atan2 goes from 0 to -pi.

Betty Boop
21-01-2012, 21:46
ohh! sorry, sir, but can you please explain the last two cases :( I've tried manual calculation using calculator :(

Ether
21-01-2012, 21:51
ohh! sorry, sir, but can you please explain the last two cases :( I've tried manual calculation using calculator :(

I edited my original response to add some detail. Please re-read it.

Then read this article:
http://en.wikipedia.org/wiki/Atan2

Then ask me a specific question and I'll gladly help.

Betty Boop
21-01-2012, 22:38
Hi! :D Now I understand :D THANK YOU VERY MUCH! :D

Ether
22-01-2012, 08:41
Hi! :D Now I understand :D THANK YOU VERY MUCH! :D

You're welcome.

May I ask: What is your interest in atan2? Are you taking a math class, or are you using it for FRC?

Betty Boop
22-01-2012, 09:46
No, Sir. I'm using it in determining the phase of a signal given its I and Q data. :D