Math.acos()

Math.acos() 静态方法返回数字的反余弦(以弧度为单位)。那是,

¥The Math.acos() static method returns the inverse cosine (in radians) of a number. That is,

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

Try it

语法

¥Syntax

js
Math.acos(x)

参数

¥Parameters

x

-1 到 1 之间的数字(包含 -1 和 1),表示角度的余弦值。

返回值

¥Return value

x 的反余弦(0 到 π 之间的弧度角(含))。如果 x 小于 -1 或大于 1,则返回 NaN

¥The inverse cosine (angle in radians between 0 and π, inclusive) of x. If x is less than -1 or greater than 1, returns NaN.

描述

¥Description

因为 acos()Math 的静态方法,所以你始终将其用作 Math.acos(),而不是用作你创建的 Math 对象的方法(Math 不是构造函数)。

¥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).

示例

¥Examples

使用 Math.acos()

¥Using Math.acos()

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

规范

Specification
ECMAScript Language Specification
# sec-math.acos

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看