サイト内検索

Math メソッド一覧

スポンサー

ホーム > Math > atan2

atan2

y / xのアークタンジェントを返します.

シンタックス

Math.atan2(x)
  • x - 数値
  • y - 数値

解説

atan2メソッドはy / xのアークタンジェントを-PIからPIまでの範囲で返します.(ラジアン単位)
これはxy座標の偏角を表します.

サンプルコード

以下にatan2メソッドを使用したサンプルコードを示します.

<html>
  <head>
    <title>atan2メソッドのサンプルコード</title>
  </head>
  <body>
    <script type="text/javascript" language="javascript">
      document.write(Math.atan2(0, 0) + "<br />");
      document.write(Math.atan2(1, 0) + "<br />");
      document.write(Math.atan2(1, 2) + "<br />");
      document.write(Math.atan2(3, 2) + "<br />");
      document.write(Math.atan2(-1, 2) + "<br />");
      document.write(Math.atan2(-3, 2));
    </script>
  </body>
</html>

実行例

サンプルコードの実行結果は以下のようになります.

0
1.5707963267948966
0.4636476090008061
0.982793723247329
-0.4636476090008061
-0.982793723247329 

関連項目

スポンサード リンク

inserted by FC2 system