Loose-Info.com
Last Update 2009/03/29
TOP - JavaScript - Math - atan2()

二つの引数の比率y/xのアークタンジェントの値を返します。結果はラジアンで-π 〜 +πの範囲となります。


戻り値1 = Math.atan2( 値1 , 値2 )

戻り値1
(値1 ÷ 値2)のアークタンジェント


(例)
<SCRIPT type="text/javascript"> <!-- function btnclick() { var s = ""; s += "Math.atan2(5,3) = " + Math.atan2(5, 3) + " → ラジアン\n"; s += "座標(x=3, y=5)のx軸との角度 : (Math.atan2(5,3) / Math.PI) * 180 = " + (Math.atan2(5, 3) / Math.PI) * 180 + "\n"; alert(s); } //--> </SCRIPT>
図1