When adapting an Excel formula ATAN2(Value1, Value2) for use in Spotfire, the argument order must be reversed: ATan2(Value2, Value1).

When adapting an Excel formula ATAN2(Value1, Value2) for use in Spotfire, the argument order must be reversed: ATan2(Value2, Value1).

book

Article ID: KB0074861

calendar_today

Updated On:

Products Versions
Spotfire Analyst All supported versions

Description

When adapting an Excel formula ATAN2(Value1, Value2) for use in Spotfire, the argument order must be reversed: ATan2(Value2, Value1).

This article explains why the arguments must be specified in the opposite order.

Issue/Introduction

When adapting an Excel formula ATAN2(Value1, Value2) for use in Spotfire, the argument order must be reversed: ATan2(Value2, Value1).

Environment

All supported environments

Resolution

Spotfire's ATan2() function returns the arctangent of two arguments as an angle expressed in radians (in the interval -PI and PI). The signs of the arguments are used to determine the quadrant of the result. The arguments and the result are of type Real.

Spotfire uses the ATan2( y-coordinate, x-coordinate ) convention, which matches the convention used in R and TERR (and in C and C++) but is different from Microsoft Excel's ATAN2( x-coordinate, y-coordinate ) convention.

This means that a Spotfire user who adapts an existing MS Excel formula ATAN2(Value1, Value2) for use in Spotfire needs to reverse the order of the arguments, to be ATan2(Value2, Value1).



The following numeric examples illustrate the behavior in Spotfire.  These can be used for comparing the behavior of Spotfire's ATan2()  function with the behavior of atan2() functions in other software applications and programming languages.

In Spotfire, 

ATan2(0, -1)

returns pi:

3.141593

and 

ATan2(-1, 0)

returns -pi/2:

-1.570796

Additional Information

Spotfire:  the help topic that is opened by selecting "Help > Help Topics > Math Functions" from the Spotfire desktop client's main menu.


Microsoft Excel:

https://www.techonthenet.com/excel/formulas/atan2.php#:~:text=The%20Microsoft%20Excel%20ATAN2%20function,function%20(WS)%20in%20Excel.


TIBCO Enterprise Runtime for R (TERR):  the "Inverse Trigonometric Functions" help topic that is opened by the following command in a TERR Console session:

?atan2