### Math.atan2() Method

This function returns an implementation-dependent approximation to the arctangent of the quotient of its parameters.

##### Syntax

Math.atan2(y, x)

Parameter
Description

y

The value on the y axis

x

The value on the x axis

##### Returns

An implementation-dependent approximation of the arctangent of y/x, in radians.

##### Usage

This function returns an implementation-dependent approximation to the arctangent of the quotient, y/x, of the parameters y and x, where the signs of the parameters are used to determine the quadrant of the result. It is intentional and traditional for the two-parameter arctangent function that the parameter named y be first and the parameter named x be second. The return value is expressed in radians and ranges from -pi to +pi.

##### Example

This example finds the roof angle necessary for a house with an attic ceiling of 8 feet (at the roof peak) and a 16-foot span from the outside wall to the center of the house. The Math.atan2() function returns the angle in radians; it is multiplied by 180/PI to convert it to degrees. Compare the example in the discussion of Math.atan() Method to understand how the two arctangent functions differ. Both examples return the same value.

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.")
}