Math.atan()

Math.atan() 関数は、引数として与えた数値のアークタンジェントをラジアン単位で返します。

Math.atan ( x ) = arctan ( x ) = the unique y [ - π 2 ; π 2 ] such that tan ( y ) = x \mathtt{\operatorname{Math.atan}(x)} = \arctan(x) = \text{ the unique } ; y \in \left[-\frac{\pi}{2}; \frac{\pi}{2}\right] , \text{such that} ; \tan(y) = x

試してみましょう

構文

Math.atan(x)

引数

x

数値です。

返値

与えられた数値のアークタンジェント (ラジアン単位) です。

解説

Math.atan() メソッドは - π 2 -\frac{\pi}{2} から π 2 \frac{\pi}{2} までのラジアンの数値を返します。

atan()Math の静的メソッドであるため、生成した Math オブジェクトのメソッドとしてではなく、常に Math.atan() として使用するようにしてください (Math はコンストラクターではありません)。

Math.atan() の使用

js
Math.atan(1); // 0.7853981633974483
Math.atan(0); // 0
Math.atan(-0); // -0

Math.atan(Infinity); //  1.5707963267948966
Math.atan(-Infinity); // -1.5707963267948966

// The angle that the line [(0,0);(x,y)] forms with the x-axis in a Cartesian coordinate system
Math.atan(y / x);

様式上の理由から ±Infinity の使用を避けたいと思うことがあるかもしれません。その場合、 Math.atan2() を第二引数を 0 としてを使うとよりよいかもしれません。

仕様書

Specification
ECMAScript Language Specification
# sec-math.atan

ブラウザーの互換性

BCD tables only load in the browser

関連情報