What is the method for converting radians to degrees?
Asked Answered
G

12

177

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?

Gina answered 25/9, 2008 at 20:40 Comment(10)
I don't see why people are downvoting this; some people aren't mathematically inclined.Ackack
its just a matter of phrasing. I rephrased it as a programming problem instead of a math problem, and voila, it fits.Danieldaniela
Excellent, I truly believe these kinds of basic questions have a place on stack overflow if it is to be the programming information portal of reckon.Gina
The title of this question makes no sense. "[B]uilt in method" --- built in to what?Polyhydroxy
Heck if I know, someone edited it.Gina
so, for a 2 second google search you would get 31+ points and for a one-line answer someone will get 100+ points? sigh...Fondea
i am going to go ask for a method for converting Celsius to Fahrenheit and back, i keep forgetting that one tooFondea
@alex, you do that now you'll be trashed; this is a very old question and the site has moved on. Flag it as off-topic and don't let it bother you...Googol
@Ben, i did not notice the date, but in case you did not recognize it, it was sarcasm.Fondea
StackOverflow is more than a forum for questions and answers. It's a place of reference. I originally put the question here as a reference question, because it's really really common. It belongs here so when someone answers "Just Google it", Google will direct you here.Gina
A
307
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

Aidaaidan answered 25/9, 2008 at 20:43 Comment(6)
Pi = 4 * ArcTan(1) could be used, in case you don't have Pi on you system/calculator or just don't want to type it in with all decimalsSkid
Maybe this wasn't available in 2008, but nowadays you can just use the Math.PI constant.Tellurize
is this correct?? PI radians = 180 degrees radians = 180 degrees / PI radians = 180/PI * degrees i don't known your formula. why are 180 and PI changed?Understudy
@Understudy Unit labels are not the same thing as algebraic variables. When you say "PI radians = 180 degrees" you are speaking in units, equivalent to saying "1 foot = 12 inches". You don't then take the unit labels and treat them as variables, which would give you the obviously wrong equation "feet = 12*inches".Aidaaidan
No need for parens degrees = radians * 180 / Math.PI; radians = degrees * Math.PI / 180;Contraption
@Contraption While you are correct, I dare say the author used the parens to convey a concept about how the function comes together conceptually.Moffit
P
11

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.

Polaris answered 25/9, 2008 at 20:44 Comment(0)
A
9

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.

Ackack answered 25/9, 2008 at 20:43 Comment(0)
B
7

In javascript you can do it this way

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

degrees = radians * (180/Math.PI);
Billet answered 15/6, 2016 at 7:40 Comment(0)
H
0

This works well enough for me :)

// deg2rad * degrees = radians
#define deg2rad (3.14159265/180.0)
// rad2deg * radians = degrees
#define rad2deg (180/3.14159265)
Harpist answered 1/4, 2012 at 4:35 Comment(0)
J
0

.NET8: https://github.com/dotnet/runtime/issues/86402

double.RadiansToDegrees(1);
float.DegreesToRadians(1);
Jacobi answered 23/3 at 2:3 Comment(0)
B
-1

180 degrees = PI * radians

Boadicea answered 25/9, 2008 at 20:43 Comment(1)
180 degrees = pi radians.Tilley
E
-1

360 degrees is 2*PI radians

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

Erupt answered 25/9, 2008 at 20:43 Comment(0)
D
-1

360 degrees = 2*pi radians

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

Diastrophism answered 25/9, 2008 at 20:44 Comment(0)
P
-1

pi Radians = 180 degrees

So 1 degree = pi/180 radians

or 1 radian = 180/pi degrees

Personality answered 25/9, 2008 at 20:44 Comment(0)
S
-1

Here is some code which extends Object with rad(deg), deg(rad) and also two more useful functions: getAngle(point1,point2) and getDistance(point1,point2) where a point needs to have a x and y property.

Object.prototype.rad = (deg) => Math.PI/180 * deg;
Object.prototype.deg = (rad) => 180/Math.PI * rad;
Object.prototype.getAngle = (point1, point2) => Math.atan2(point1.y - point2.y, point1.x - point2.x);
Object.prototype.getDistance = (point1, point2) => Math.sqrt(Math.pow(point1.x-point2.x, 2) + Math.pow(point1.y-point2.y, 2));
Surbeck answered 7/6, 2020 at 7:33 Comment(0)
G
-2
radians = (degrees/360) * 2 * pi
Glasgow answered 25/9, 2008 at 20:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.