What is the method for converting radians to degrees?
Solution 1
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
Solution 2
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.
Solution 3
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.
Solution 4
In javascript you can do it this way
radians = degrees * (Math.PI/180);
degrees = radians * (180/Math.PI);
Solution 5
This works well enough for me :)
// deg2rad * degrees = radians
#define deg2rad (3.14159265/180.0)
// rad2deg * radians = degrees
#define rad2deg (180/3.14159265)
Related videos on Youtube
Hans Sjunnesson
I'm the Head of Code at Fatshark. We're a nice little video game studio, in Stockholm, Sweden - most recently famous for Warhammer: Vermintide 2.
Updated on June 08, 2020Comments
-
Hans Sjunnesson almost 4 years
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?
-
Tanky Woo over 15 yearsI don't see why people are downvoting this; some people aren't mathematically inclined.
-
DevelopingChris over 15 yearsits just a matter of phrasing. I rephrased it as a programming problem instead of a math problem, and voila, it fits.
-
Hans Sjunnesson over 15 yearsExcellent, 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.
-
Michael J. Barber over 12 yearsThe title of this question makes no sense. "[B]uilt in method" --- built in to what?
-
Hans Sjunnesson over 12 yearsHeck if I know, someone edited it.
-
Alex over 11 yearsso, for a 2 second google search you would get 31+ points and for a one-line answer someone will get 100+ points? sigh...
-
Alex over 11 yearsi am going to go ask for a method for converting Celsius to Fahrenheit and back, i keep forgetting that one too
-
Ben over 11 years@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...
-
Alex over 11 years@Ben, i did not notice the date, but in case you did not recognize it, it was sarcasm.
-
Hans Sjunnesson over 11 yearsStackOverflow 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.
-
-
Axel Kemper over 11 yearsPi = 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 decimals
-
garg over 10 years180 degrees = pi radians.
-
Bart about 10 yearsMaybe this wasn't available in 2008, but nowadays you can just use the
Math.PI
constant. -
Hogun about 10 yearsis 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?
-
Dave Costa about 10 years@Hogun 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".
-
Pawel over 7 yearsNo need for parens degrees = radians * 180 / Math.PI; radians = degrees * Math.PI / 180;
-
Jacksonkr about 7 years@Pawel While you are correct, I dare say the author used the parens to convey a concept about how the function comes together conceptually.