Seems as thought javascript doesnt come shipped with functions to convert radians to degrees and degrees to radians. Here’s a quick snippet to save you the headache of searching the net for the code
Math.degrees = function(rad)
{
return rad*(180/Math.PI);
}
Math.radians = function(deg)
{
return deg * (Math.PI/180);
}
Use it like any other function in javacsript’s Math object:
var angle_in_deg = Math.degrees(3.14); var angle_in_rad = Math.radians(180);
enjoy 😀
How to write –> a = b * cos(40 Degrees) – c * sin(40 Degrees);
in JS?
using the functions from the code in this post, just do this:
a = b*cos(Math.radians(40)) – c*sin(Math.radians(40));
Thanks man! it works XD
you’re welcome 🙂