PHP atan2 function – Arc tangent of two variables

Description

This function returns the value of the arctangent of the point denoted by the x and y parameters. The return value is in radians, in the range -pi to pi (approximately -3.14 to 3.14). 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.

Syntax:

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

Parameters

Parameter Description
y Dividend parameter
x Divisor parameter

Return Values

The arc tangent of y/x in radians.

Examples

Example 1:
Calculate the arctangent of a coordinate:

$tanx = -1; 
$tany = 1; 
echo "The arctangent of $tanx/$tany is ", atan2($tanx, $tany)
Related Post