Movatterモバイル変換


[0]ホーム

URL:


  1. 開発者向けのウェブ技術
  2. JavaScript
  3. JavaScript リファレンス
  4. 標準組み込みオブジェクト
  5. Math
  6. acos()

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docsコミュニティーについてもっと知り、仲間になるにはこちらから。

View in EnglishAlways switch to English

Math.acos()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2015年7月⁩.

Math.acos() は静的メソッドで、引数として与えた数値の逆余弦(アークコサイン)をラジアン単位で返します。すなわち次の通りです。

x[1,1],𝙼𝚊𝚝𝚑.𝚊𝚌𝚘𝚜(𝚡)=arccos(x)=the unique y[0,π] such that cos(y)=x\forall x \in [{-1}, 1],\;\mathtt{\operatorname{Math.acos}(x)} = \arccos(x) = \text{the unique } y \in [0, \pi] \text{ such that } \cos(y) = x

試してみましょう

// 直角三角形の角度をラジアンで計算するfunction calcAngle(adjacent, hypotenuse) {  return Math.acos(adjacent / hypotenuse);}console.log(calcAngle(8, 10));// 予想される結果: 0.6435011087932843console.log(calcAngle(5, 3));// 予想される結果: NaN

構文

js
Math.acos(x)

引数

x

コサインを表す数値で、x-11 の間です。

返値

与えられた数値が-1 から1 までの場合、その逆余弦(アークコサイン)をラジアン単位で返します。それ以外の場合はNaN を返します。

解説

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

Math.acos() の使用

js
Math.acos(-2); // NaNMath.acos(-1); // 3.141592653589793 (π)Math.acos(0); // 1.5707963267948966 (π/2)Math.acos(0.5); // 1.0471975511965979 (π/3)Math.acos(1); // 0Math.acos(2); // NaN

仕様書

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

ブラウザーの互換性

関連情報

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp