This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always 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 ] , Math.acos ( x ) = 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

์‹œ๋„ํ•ด ๋ณด๊ธฐ

// Calculates angle of a right-angle triangle in radians
function calcAngle(adjacent, hypotenuse) {
  return Math.acos(adjacent / hypotenuse);
}

console.log(calcAngle(8, 10));
// Expected output: 0.6435011087932843

console.log(calcAngle(5, 3));
// Expected output: NaN

๊ตฌ๋ฌธ

js
Math.acos(x);

๋งค๊ฐœ๋ณ€์ˆ˜

x

๊ฐ๋„๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋ผ๋””์•ˆ.

๋ฐ˜ํ™˜ ๊ฐ’

-1๊ณผ 1 ์‚ฌ์ด์˜ ๊ฐ’์ด ์ฃผ์–ด์ง„ ๊ฒฝ์šฐ, ๊ทธ ๊ฐ’์˜ ์•„ํฌ์ฝ”์‚ฌ์ธ. ์•„๋‹ ๊ฒฝ์šฐ NaN

์„ค๋ช…

The Math.acos() method returns a numeric value between 0 and ฯ€ radians for x between -1 and 1. If the value of x is outside this range, it returns NaN.

Because acos() is a static method of Math, you always use it as Math.acos(), rather than as a method of a Math object you created (Math is not a constructor).

์˜ˆ์ œ

Using Math.acos()

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

For values less than -1 or greater than 1, Math.acos() returns NaN.

๋ช…์„ธ

Specification
ECMAScriptยฎ 2026 Language Specification
# sec-math.acos

๋ธŒ๋ผ์šฐ์ € ํ˜ธํ™˜์„ฑ

See also