The built-in math function
atan() determines the arc tangent of a given value. It is also known as the inverse tangent function, it identifies the angle whose tangent is equal to the specified value. The inverse function of
atan() is the
$result = atan($number);
atan() function takes one parameter:
$number(required): The number for which the arc tangent is to be calculated.
atan() method returns a floating point number which is the arc tangent value of the number passed. The resulting numeric value will be between -pi/2 and pi/2 radians.
To convert radians to degrees, use the following:
$degrees = $radians * ( 180.0 / M_PI );
The example below illustrates the use of the
atan() function to calculate the arc tangent of a number and print the result.
<?phpecho("atan(0.5): " . atan(0.5) . " Radians");?>
This will result in the following output:
atan(0.5): 0.46364760900081 Radians
The example below uses the
atan() function to obtain the arc tangent value of a number in radians, and then converts it into degrees.