# atan2()

float atan2 ( float \$y, float \$x )

## Description

atan2() calculates the arc tangent of the two variables \$x and \$y. It is similar to calculating the arc tangent of \$y/\$x, except that the signs of both arguments are used to determine the quadrant of the result.

※ available F/W version : all

## Parameters

• \$y - Dividend parameter
• \$x - Divisor parameter

## Return values

Returns the arc tangent of \$y/\$x in radians

## Example

``````<?php
\$y = 1.0;\$x = 2.0;
\$y3 = -1.0;\$x3 = -2.0;

\$rad = \$y/\$x;
\$val1 = atan(\$rad);
\$val2 = atan2(\$y, \$x);
\$val3 = atan2(\$y3, \$x3);
\$val4 = tan(\$val1);

echo "atan(\$rad) = \$val1\r\n";  // OUTPUT: atan(0.5) = 0.46364760900081
echo "atan2(\$y, \$x) = \$val2\r\n";  // OUTPUT: atan2(1, 2) = 0.46364760900081
echo "atan2(\$y3, \$x3) = \$val3\r\n";  // OUTPUT: atan2(-1, -2) = -2.677945044589
echo "tan(\$val1) = \$val4\r\n";  // OUTPUT: tan(0.46364760900081) = 0.5
?>``````

## Remarks

This function is identical to the PHP group’s atan2() function.