What is the method for converting radians to degrees?

a complete circle in radians is 2*pi. A complete circle in degrees is 360. To go from degrees to radians, it's (d/360) * 2*pi, or d*pi/180.


x rads in degrees - > x*180/pi
x degrees in rads -> x*pi/180

I guess if you wanted to make a function for this [in PHP]:

function convert($type, $num) {
    if ($type == "rads") {
          $result = $num*180/pi();
        }

    if ($type == "degs") {
          $result = $num*pi()/180;
        }

    return $result;
  }

Yes, that could probably be written better.


radians = degrees * (pi/180)

degrees = radians * (180/pi)

As for implementation, the main question is how precise you want to be about the value of pi. There is some related discussion here


In javascript you can do it this way

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

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