PHP atan2()函数

PHP atan2()函数

PHP atan2()也是一个预定义的三角函数,用于返回两个变量x和y的反正切,或者返回不同点(x,y)的角度theta,使用atan2()函数。

注意:弧度中y/x的反正切的范围在-Pi和Pi之间。

语法

    atan2(y,x);
Parameter Description Required/Optional
X Specify the dividend Required
Y Specify the divisor Required

示例1

<?php
echo "Your number is : (0.50,0.50)";
echo "<br>"."By using 'atan2()' function your number is :".(atan2(0.50,0.50));
?>

输出:

Your number is : (0.50,0.50)
By using 'atan2()' function your number is :0.78539816339745

示例2

<?php
echo "Your number is : (-0.50,-0.50)";
echo "<br>"."By using 'atan2()' function your number is :".(atan2(0.50,0.50));
?>

输出:

Your number is : (-0.50,-0.50)
By using 'atan2()' function your number is :0.78539816339745

示例3

<?php
echo "Your number is : (5,5)";
echo "<br>"."By using 'atan2()' function your number is :".(atan2(5,5));
?>

输出:

Your number is : (5,5)
By using 'atan2()' function your number is :0.78539816339745

示例4

<?php
echo "Your number is : (-5,-5)";
echo "<br>"."By using 'atan2()' function your number is :".(atan2(-5,-5));
?>

输出:

Your number is : (-5,-5)
By using 'atan2()' function your number is :-2.3561944901923 

示例5

<?php
echo "Your number is : (-5,5)";
echo "<br>"."By using 'atan2()' function your number is :".(atan2(-5,5));
?>

输出:

Your number is : (-5,5)
By using 'atan2()' function your number is :-0.78539816339745

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程