What is the method for converting radians to degrees?
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
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.
In javascript you can do it this way
radians = degrees * (Math.PI/180);
degrees = radians * (180/Math.PI);
This works well enough for me :)
// deg2rad * degrees = radians
#define deg2rad (3.14159265/180.0)
// rad2deg * radians = degrees
#define rad2deg (180/3.14159265)