PHP atan2() Function

❮ PHP Math Reference

Example

Return the arc tangent of two variables with the atan2() function:

<?php
echo(atan2(0.50,0.50) . "<br>");
echo(atan2(-0.50,-0.50) . "<br>");
echo(atan2(5,5) . "<br>");
echo(atan2(10,20) . "<br>");
echo(atan2(-5,-5) . "<br>");
echo(atan2(-10,10));
?>
Try it Yourself »

Definition and Usage

The atan2() function returns the arc tangent of y/x, in radians. Where x and y are the coordinates of a point (x,y).


Syntax

atan2(y,x);

Parameter Values

Parameter Description
y Required. Specifies a positive or negative number
x Required. Specifies a positive or negative number

Technical Details

Return Value: The arc tangent of y/x in radians, which is between -PI and PI
Return Type: Float
PHP Version: 4+

❮ PHP Math Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.