The word radian comes from radius, which is half the diameter of a circle. If you take a radius and create an arc along the circle of the same length, you get one radian.
Okay. So what?
First, to understand the radian, gander at Figure 1. You see how the radius of the circle on the left is mapped to an arc on the circle. This length is one radian, r.
The radian is related to π, which is the ratio of the circle’s diameter to its circumference. As the radius is half the diameter, its value is related to π, as you see in the measurements in the circle on the left: For the entire circle, the radian wraps around the circumference 6.2831 times, which is 2π. This number makes sense because the circle’s diameter wraps around the circumference 3.1415 times, which is 1π.
Degrees, shown on the right in Figure 1, were invented to divide a circle into handy portions. No one knows who came up with the idea, but the Babylonians used a base 60 (sexagesimal) numbering system, so they get the credit. Further, 360 is a number than can be divided by many other numbers and you still get a whole number answer.
Second, why do computers use radians and not degrees?
Consider the triangles shown in Figure 2.
On the right you see a triangle measured in degrees, which you probably studied in school, the common 30-60-90 triangle. On the left is the same triangle, but with measurements in radians. 30° is π/6 radians, 60° is π/3 radians, and 90° is π/2 radians. As you might suspect, computers find these values far easier to deal with than degrees.
Oh, and 45° is π/4 radians.
It’s not critical to know the specific decimal values of the π ratios when dealing with radians. Instead, as a programmer, you just need to know the translation constants:
To convert degrees to radians, multiply degrees by 0.0174532925. This value is 2π/360.
To convert radians to degrees, multiply radians by 57.2957795. This value is 360/2π.
The following code displays common angles as radians and degrees.
#include <stdio.h> #define PI 3.1415926 int main() { float degree,radian; for(degree=0.0;degree<=360.0;degree+=60.0) printf("%.f degrees = %.4f radians\n", degree, degree*0.0174533 ); for(radian=0.0;radian<=PI*2;radian+=(PI/3.0)) printf("%.4f radians = %.f degrees\n", radian, radian*57.2958 ); return(0); }
Because of the way the loops work, I’m not able to display π ratios in the code, but you can see the values of π in the output:
0 degrees = 0.0000 radians
60 degrees = 1.0472 radians
120 degrees = 2.0944 radians
180 degrees = 3.1416 radians
240 degrees = 4.1888 radians
300 degrees = 5.2360 radians
360 degrees = 6.2832 radians
0.0000 radians = 0 degrees
1.0472 radians = 60 degrees
2.0944 radians = 120 degrees
3.1416 radians = 180 degrees
4.1888 radians = 240 degrees
5.2360 radians = 300 degrees
6.2832 radians = 360 degrees
Back to the code from last week’s Lesson, here’s the proper way to do the math with radians instead of degrees:
#include <stdio.h> #include <math.h> #define DEG2RAD 0.0174532925 int main() { printf("The sine of 45 degrees is %f\n",sin(45*DEG2RAD)); printf("The cosine of 45 degrees is %f\n",cos(45*DEG2RAD)); printf("The tan of 45 degrees is %f\n",tan(45*DEG2RAD)); return(0); }
In the code, I use the DEG2RAD
constant expression to modify 45 from a degree value to radians.
Here’s the proper output:
The sine of 45 degrees is 0.707107
The cosine of 45 degrees is 0.707107
The tan of 45 degrees is 1.000000
That looks better!
Thanks for the post. I always #define 57.29577951 rather than 0.0174532925, which are just reciprocals of each other. As long as you remember when to multiply and when to divide it doesn’t matter which you use.
Years ago I actually made the effort to memorize 57.29577951 which probably makes me a nerd. Or a geek. Or both.
But if you memorize π, you can just divide or multiply accordingly and that’s it!
BTW, I’ve been reading and enjoying your site. I admire how technical your posts can get, which can be very helpful. Your post on linear regression was useful to help me solve a problem recently.
http://www.code-in-c.com/linear-regression-fitting-a-line-to-data/
So you want me to memorize pi as well? It took me about 2 years to remember my new phone number . . .
Glad you found my linear regression post useful. I started using Google Search Console a while ago and that post is the most popular, at least in terms of people finding it via Google. (It’s probably mostly students given an assignment Googling and then copy/pasting my code!)
I also used radians in my Great Circle Distance post. It makes it much more straightforward than using degrees.
Did you create the first graphic with the two circles or did you “borrow” it from somewhere? The calculations using π seem a bit too complicated, it might be simpler to use:
0πr
0.5πr
1πr
1.5πr
2πr
etc.
I created the graphics myself, which is why the circle on the right isn’t transparent. My Mac doesn’t have a high-contrast monitor, but my laptop does. So when I looked at it after posting, I was like, “Yuck.”
You’re correct about the decimal notation, which I agree is easier to read. I was thinking more in terms ratio values, as shown on the left in Figure 1.
Reader Jacco made the following keen observations regarding measuring angles in an email to me. The following is reprinted with his permission:
Thank you! I did, and I hope others enjoy it as well.