Math.atan()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Math.atan() は静的メソッドで、数値の逆正接(アークタンジェント)をラジアン単位で返します。

𝙼𝚊𝚝𝚑.𝚊𝚝𝚊𝚗(𝚡)=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

試してみましょう

// Calculates angle of a right-angle triangle in radians function calcAngle(opposite, adjacent) { return Math.atan(opposite / adjacent); } console.log(calcAngle(8, 10)); // Expected output: 0.6747409422235527 console.log(calcAngle(5, 3)); // Expected output: 1.0303768265243125 

構文

js
Math.atan(x) 

引数

x

数値です。

返値

-π2-\frac{\pi}{2}π2\frac{\pi}{2} で両端を含むラジアン単位の角度である) x の逆正接(アークタンジェント)です。 xInfinity である場合は π2\frac{\pi}{2} を返します。 x gが -Infinity である場合、 -π2-\frac{\pi}{2} を返します。

解説

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

Math.atan() の使用

js
Math.atan(-Infinity); // -1.5707963267948966 (-π/2) Math.atan(-0); // -0 Math.atan(0); // 0 Math.atan(1); // 0.7853981633974483 (π/4) Math.atan(Infinity); // 1.5707963267948966 (π/2) // The angle that the line (0,0) -- (x,y) forms with the x-axis in a Cartesian coordinate system const theta = (x, y) => Math.atan(y / x); 

シータ関数を避け、代わりに Math.atan2() を使用することをお勧めします。これは、より広い範囲(-π から π まで)を保有しており、x0 の場合など、 NaN を出力しないようにします。

仕様書

Specification
ECMAScript® 2026 Language Specification
# sec-math.atan

ブラウザーの互換性

関連情報