in this tutorial we will discuss javascript user defined function for degree and radiance.These fucntion are very important when you are doing mathemtical calculation based trigonometry.I have taken refrence from other website and change as per our requirment.You feel free to take it and use it in your code.
Converts from degrees to radians:
1 2 3 |
Math.radians = function(degrees) {
return degrees * (Math.PI / 180);
};
|
Converts from radians to degrees:
1 2 3 |
Math.degrees = function(radians) {
return radians * (180 / Math.PI);
};
|
How to use:
1 2 |
alert(Math.radians(60)); // 1.0471975511965976
alert(Math.radians(90)); // 1.5707963267948966
|