Math class contains the following methods for performing trigonometric functions:
Method | Description |
---|---|
sin(radians) | Returns the trigonometric sine of an angle in radians. |
cos(radians) | Returns the trigonometric cosine of an angle in radians. |
tan(radians) | Returns the trigonometric tangent of an angle in radians. |
toRadians(degree) | Returns the angle in radians for the angle in degree. |
toDegree(radians) | Returns the angle in degrees for the angle in radians. |
asin(a) | Returns the angle in radians for the inverse of sine. |
acos(a) | Returns the angle in radians for the inverse of cosine. |
atan(a) | Returns the angle in radians for the inverse of tangent. |
Math.toDegrees(Math.PI / 2) //90.0 Math.toRadians(30) //0.5236 (same as pi/6) Math.sin(0) //0.0 Math.sin(Math.toRadians(270)) //-1.0 Math.sin(Math.PI / 6) //0.5 Math.sin(Math.PI / 2) //1.0 Math.cos(0) //1.0 Math.cos(Math.PI / 6) //0.866 Math.cos(Math.PI / 2) //0 Math.asin(0.5) //0.523598333 (same as PI/6) Math.acos(0.5) //1.0472 (same as PI/3) Math.atan(1.0) //0.785398 (same as PI/4)