how can I calculate sin, cos and tan values in javascript?
or
what are the different trigonometric methods available in Math object?
Explanation
Object: Math
We can also calculate trigonometrical values using the
predefined math object methods or function. We can calculate sin, cos,
tan, arc cosine, arc sine, arc tan values.
The get the value for angle or degree, e.g: sin(30o), convert the degree to radians when
using Math.sin method. i.e: Math.sin(30*Math.PI/180).
The below table lists the methods and their usage.
Constant
Example Code
Result
Description
sin(int)
Math.sin(1);
Math.sin(x) where x in radians returns the sine value of x.
cos(int)
Math.cos(1);
Math.cos(x) returns the cosine value of x.
tan(int)
Math.tan(1);
Math.tan(1) returns the tangent value of x.
asin(int)
Math.asin(1);
Math.asin(x) returns the arc sine value of radians.
acos(int)
Math.acos(1);
Math.acos(x) returns the arc cosine value of radians.
atan(int)
Math.atan(1);
Math.atan(x) returns the arc tangent value of radians.
Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script.
Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.