Home >>PHP Math Functions >PHP atan2() Function

PHP atan2() Function

PHP atan2() Function

PHP atan2() function is used to calculate the arc tangent of two given input variables x and y passed to it as the arguments. It returns the output in radians having the value between -Pi and Pi.

Syntax:

   atan2($x,$y);

Parameter Values

Parameter Description
X This is a required parameter. This parameter defines the dividend.
Y This is a required parameter. This parameter defines the divisor.

Here is an example of atan2() function in PHP:

<html>
<body>

<?php

echo atan2(0.59,0.59)."<br>";
echo atan2(-0.78,-0.78)."<br>";
echo atan2(10,5)."<br>";

?>

</body>
</html>
Output:
0.78539816339745
-2.3561944901923
1.1071487177941

Here is an another example of atan2() function in PHP:

<html>
<body>

<?php

echo atan2(10,10)."<br>";
echo atan2(-10,-10)."<br>";
echo atan2(10,-5)."<br>";
echo atan2(-10,5)."<br>";

?>

</body>
</html>
Output:
0.78539816339745
-2.3561944901923
2.0344439357957
-1.1071487177941

No Sidebar ads