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