该例子取得不同点的角度:
<script language="JavaScript"> document.write( Math.atan2(1.5,1.5) + "<br />" ); document.write( Math.atan2(-1.5,-1.5) + "<br />" ); document.write( Math.atan2(5,10) + "<br />" ); document.write( Math.atan2(0,5) ); </script>
运行该例子,输出:
0.7853981633974483 -2.356194490192345 0.4636476090008061 0