Converting Between Degrees and Radians

Converting Between Degrees and Radians


You have an angle in degrees. To use the value in the Math object’s trigonometric func‐ tions, you need to convert the degrees to radians. 


To convert degrees to radians, multiply the value by (Math.PI / 180):

var radians = degrees * (Math.PI / 180);

To convert radians to degrees, multiply the value by (180 / Math.PI):

var degrees = radians * (180 / Math.PI);


All Math trigonometric methods (sin(), cos(), tin(), asin(), acos(), atan(), and atan2()), take values in radians, and return radians as a result.

Yet it’s not unusual for people to provide values in degrees rather than radians, as degrees are the more familiar unit of measure.

he functionality covered in the solution provides the conversion between the two units. 


Post a Comment