abs(x)
var x= Math. abs ( - 5 )
floor(x)
var x= Math. floor ( 2.1 )
ceil(x)
var x= Math. ceil ( 2.1 )
fround(x)
var x= Math. fround ( 2.60 )
random()
var x= Math. floor ( ( Math. random ( ) * 10 ) + 1 )
round(x)
var x= Math. round ( 2.5 )
pow(x, y)
var x= Math. pow ( 4 , 3 )
min(x, y, z, …, n)
var x= Math. min ( 5 , 10 )
max(x, y, z, …, n)
var x= Math. max ( 5 , 10 )
sin(rotate)
返回 rotate 的正弦值(rotate 以弧度为单位)
var a;
var b;
var c;
var rotate= 30
var sinX= Math. sin ( rotate* ( Math. PI / 180 ) )
cos(rotate)
返回 rotate 的余弦值(x 以弧度为单位))
var a;
var b;
var c;
var rotate= 30
var cosX= Math. cos ( rotate* ( Math. PI / 180 ) )
tan(rotate)
返回 rotate 的正切值(x 以弧度为单位))
var a;
var b;
var c;
var rotate= 30
var cosX= Math. tan ( rotate* ( Math. PI / 180 ) )
cot(rotate)
返回 rotate 的余切值(x 以弧度为单位))
var a;
var b;
var c;
var rotate= 30
var cosX= Math. cot ( rotate* ( Math. PI / 180 ) )
角度与弧度换算
js计算三角函数
var sin30 = Math. sin ( 30 * Math. PI / 180 )
console. log ( sin30) ;
var cos60 = Math. cos ( 60 * Math. PI / 180 )
console. log ( cos60) ;
var tan45 = Math. tan ( 45 * Math. PI / 180 )
console. log ( tan45) ;
js计算反三角函数
asin、acos、atan计算出来的都是弧度,通过方法转换为角度
var asin30 = Math. round ( Math. asin ( sin30) * 180 / Math. PI )
console. log ( asin30) ;
var acos60 = Math. round ( Math. acos ( cos60) * 180 / Math. PI )
console. log ( acos60) ;
var atan45 = Math. round ( Math. atan ( tan45) * 180 / Math. PI )
console. log ( atan45) ;