JS: Math trig functions. sin, cos, tan, asin, acos, atan
Math.sin(x)-
Sine function.
All trig functions's argument are radians.
console.log( Math.sin(3.14) ) // 0.0015926529164868282 console.log( Math.sin(Math.PI) ) // 1.2246467991473532e-16 Math.cos(x)-
Cosine function.
Math.tan(x)-
Tangent function.
Math.asin(x)-
Inverse of sine. Domain is -1 to 1. Range is 0 to pi.
Math.acos(x)-
Inverse of cosine. Domain is -1 to 1. Range is 0 to pi.
Math.atan(x)-
Inverse of tangent. No restriction on domain. Range is -pi/2 to pi/2.
Math.atan2(y, x)-
Return the arc tangent of the quotient y/x, where the signs of y and x are used to determine the quadrant of the result. Result is in range from −pi to +pi.
convert degree and radian
// convert degree to radian let xdegree = 89; console.log( "xradian is:", xdegree * Math.PI / 180); // xradian is: 1.5533430342749535 // s------------------------------ // convert radian to degree let xradian = 1.55; console.log( "degree is:", xradian * 180 / Math.PI); // degree is: 88.8084582452776
JavaScript. math functions.
- JS: Math (namespace)
- JS: Math. max, min
- JS: Math. sign, abs
- JS: Math ceiling, floor, round, truncate
- JS: Math. random
- JS: Power and Roots
- JS: Math exponential and logarithm
- JS: Math constants. pi, e, sqrt, etc.
- JS: Math trig functions. sin, cos, tan, asin, acos, atan
- JS: Math hyperbolic functions. sinh, cosh, tanh, etc.
- JS: Math fround, clz32, imul