LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

atan2 formula node incorrect in help docs?

According to the Help file for Formula Node functions:
atan2(x,y) Inverse Tangent (2 Input) Computes the arctangent of y/x in radians.
The order of the arguments is x,y, but I am pretty sure it should be y,x (it's behaviour seems to indicate this, and the corresponding Labview function is y,x).  Can anyone else confirm this?  If so, I'll submit it as a correction.
0 Kudos
Message 1 of 8
(5,964 Views)
Hi Paul,

What version of LabVIEW do you have ?
I tested the atan2(x,y) with LabVIEW 7.1.1 and it seems to work correctly : atan2(x,y) in a formula node computes arctan(x/y) in radian...

I post my VI in case...

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 2 of 8
(5,956 Views)
I am using Labview 8.

Your example VI produces the following:

x     y     atan2
1    0      pi/2
0   1        0
1    1       pi/4

Can you confirm what your results are in 7.1.1
0 Kudos
Message 3 of 8
(5,953 Views)
Just to add, I would have expected the following:

x     y     atan2
1    0      0
0   1       
pi/2
1    1       pi/4

So it seems either the arguments are reversed in the function, or the help docs are incorrect.  I hope it is the latter!
0 Kudos
Message 4 of 8
(5,952 Views)

Hi Paul,

You are right - the formala node atan2() function's documentation is wrong.

The documentation says "atan2(x,y)" but as you have discovered, it should read atan2(y,x).

It's easy to see how the error occured, as it's normal to write coordinates as (x,y).

Of course the error should only be corrected in the documentation, because if the function inputs were reversed to matched the existing documentation then this would break any existing code that uses the function.

Mark.

0 Kudos
Message 5 of 8
(5,945 Views)
I'm being confused by so much informations... (I should stop Guinness ... :D)

The correct value for arctan(1/0) is +/- pi/2
The correct value for arctan(0/1) is 0
The correct value for arctan(1/1) is pi/4

no ?

because this is what I get with my VI under LV 7.1.1 !

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 6 of 8
(5,942 Views)

Hi TiTou,

There is no problem with the normal VI style function (the "Inverse Tangent (2 Input)" VI function) - that's O.K.

The error is in the documentation of the equivalent formula node function (text functions, similar to "C" code) - the documentation describes the function as "atan2(x,y)" - but actually it will only give the correct result if you reverse the x and y input values i.e. atan2(y,x) - it's simply a small, but potentialy confusing, documentation error.

Amusingly, even my HP Basic documentation (Transera HTBasic) gets a bit muddled - although it correctly documents the syntax as Atn2(y,x), it then mentions Atn2(x,y) in the further description (again, accidentaly reversing y and x inputs).

Mark.

 

Message 7 of 8
(5,939 Views)
Ok , thank alot for making this point clear Mark 😉

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 8 of 8
(5,934 Views)