views:

1269

answers:

9

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?

A: 

180 degrees = PI * radians

Charles Graham
No, 180 degrees = Pi.
thesmallprint
+2  A: 

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.

thesmallprint
+2  A: 

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

Dave Costa
A: 

360 degrees is 2*PI radians

You can find the conversion formulas at: http://en.wikipedia.org/wiki/Radian#Conversion_between_radians_and_degrees.

kokos
A: 

360 degrees = 2*pi radians

That means deg2rad(x) = x*pi/180 and rad2deg(x) = 180x/pi;

kigurai
+2  A: 

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.

nsayer
A: 

pi Radians = 180 degrees

So 1 degree = pi/180 radians

or 1 radian = 180/pi degrees

manobes
A: 

radians = (degrees/360) * 2 * pi

Axeman
A: 

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

Brendan Enrick
I thinking adding a web service call to your code to have google convert radians to degrees for you is, perhaps, overkill.
nsayer