PHP | atan2( ) Function
The atan2() function is a builtin function in PHP and is used to calculate the arc tangent of two variables x and y passed to it as arguments.
The function returns the result in radians, which is between -Pi and Pi (inclusive).
Syntax:
float atan2($y, $x)
Parameters: This function accepts two parameters and are described below:
- $y: This parameter specifies the dividend.
- $x: This parameter specifies the divisor.
Return Value: It returns a float value which is the arc tangent of y/x in radians.
Examples:
Input : atan2(0.50, 0.50) Output : 0.78539816339745 Input : atan2(-0.50, -0.50) Output : -2.3561944901923 Input : atan2(5, 5) Output : 0.78539816339745 Input : atan2(10, 20) Output : 0.46364760900081
Below programs, taking different values of the parameters are used to illustrate the atan2() function in PHP:
- When (0.50, 0.50) is passed as a parameter:
<?phpecho(atan2(0.50, 0.50));?>chevron_rightfilter_noneOutput:
0.78539816339745
-
When (-0.50, -0.50) is passed as a parameter:
<?phpecho(atan2(-0.50, -0.50));?>chevron_rightfilter_noneOutput:
-2.3561944901923
- When (5, 5) is passed as a parameter:
<?phpecho(atan2(5, 5));?>chevron_rightfilter_noneOutput:
0.78539816339745
- When (10, 20) is passed as a parameter:
<?phpecho(atan2(10, 20));?>chevron_rightfilter_noneOutput:
0.46364760900081
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- How to get the function name inside a function in PHP ?
- D3.js | d3.rgb() Function
- PHP | Ds\Map last() Function
- PHP | min( ) Function
- PHP | dir() Function
- p5.js | str() function
- p5.js | box() Function
- D3.js | d3.map.set() Function
- D3.js | d3.min() function
- PHP | key() Function
- PHP | Ds\Map map() Function
- CSS | rgb() Function
- p5.js | hex() function
Reference:
http://php.net/manual/en/function.atan2.php
Recommended Posts:
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



