I run into this occasionally and always forget how to do it.
One of those things that pop up ever so often.
Also, what's the formula to convert angles expressed in radians to degrees and back again?
I run into this occasionally and always forget how to do it.
One of those things that pop up ever so often.
Also, what's the formula to convert angles expressed in radians to degrees and back again?
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 = pi * (degrees/180)
As for implementation, the main question is how precise you want to be about the value of pi. There is some related discussion here
360 degrees is 2*PI radians
You can find the conversion formulas at: http://en.wikipedia.org/wiki/Radian#Conversion_between_radians_and_degrees.
360 degrees = 2*pi radians
That means deg2rad(x) = x*pi/180 and rad2deg(x) = 180x/pi;
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.
pi Radians = 180 degrees
So 1 degree = pi/180 radians
or 1 radian = 180/pi degrees
I prefer to use the Google Calculator. http://www.google.com/search?q=6+radians+in+degrees&sourceid=navclient-ff&ie=UTF-8&rlz=1B3GGGL_enUS235US236&aq=t
All you have to do is type it into google and it gives you the answer. "6 radians in degrees" searched in google will give you this result.
6 radians = 343.774677 degrees