Get Arctangent 2 Method

The Get Arctangent 2 method returns an approximate arctangent of the value that the y argument contains divided by the value that the x argument contains, expressed in radians and ranging from negative pi through pi.

To determine the quadrant of the result, this method uses the signs of the arguments. It is intentional and traditional that the argument named y is the first argument and the argument named x is the second argument.

Format

Math.atan2(y, x)

The following table describes the arguments for the Get Arctangent 2 method.

Argument Description

y

The value on the y axis.

x

The value on the x axis.

Example for the Get Arctangent 2 Method

The following example finds the roof angle necessary for a house. It is identical to the example for the Get Arctangent method except this example uses the Get Arctangent 2 method. For more information, see Get Arctangent Method:

function RoofBtn2_Click ()

{

   var height = 8;

   var span = 16;

   var angle = Math.atan2(span, height)*(180/Math.PI);
   TheApplication().RaiseErrorText("The angle is " +

   Clib.rsprintf("%5.2f", angle) + " degrees.")

}