Angles and Radians
An angle measures an amount of turning. People usually count it in degrees, but mathematics and almost every programming library count it in radians. This lesson explains both units, how to convert between them, and why radians are the natural choice.
Two ways to measure a turn
An angle is formed by two rays that share an endpoint, the vertex. In trigonometry we usually place the vertex at the origin, start the first ray (the initial side) along the positive x-axis, and rotate to the terminal side. Counter-clockwise rotation is positive, clockwise is negative.
- Degrees split a full turn into 360 equal parts. The number 360 is historical: it has many divisors (2, 3, 4, 5, 6, 8, 9, 10, 12, ...), which made hand calculation easy.
- Radians measure the angle by the arc it cuts out of a circle. An angle of 1 radian is the angle whose arc is exactly as long as the radius.
A full circle has circumference , so a full turn is . That gives the one fact you need for every conversion:
| Degrees | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Radians |
Tip: Think "". Then is a quarter turn, is a third of a half turn (60°), and is three quarter turns.
Converting in Python
The math module has math.radians and math.degrees. SymPy keeps exact, which is handy for seeing clean fractions of :
import math
import sympy as sp
for d in [30, 45, 90, 150, 270]:
print(f"{d:>3}° = {math.radians(d):.6f} rad = {sp.Rational(d, 180) * sp.pi}")
print("1 rad =", round(math.degrees(1), 4), "degrees")
print("2.5 rad =", round(math.degrees(2.5), 2), "degrees") 30° = 0.523599 rad = pi/6
45° = 0.785398 rad = pi/4
90° = 1.570796 rad = pi/2
150° = 2.617994 rad = 5*pi/6
270° = 4.712389 rad = 3*pi/2
1 rad = 57.2958 degrees
2.5 rad = 143.24 degrees
SymPy prints as pi and multiplication as *, so 5*pi/6 means .
Why radians are natural
With radians, arc length and sector area have the simplest possible formulas, with no stray conversion factors:
In degrees the same formulas need a factor . Radians also make calculus clean: the fact that for small (and that the derivative of is ) is only true when is in radians. You will see this in the trig functions lesson of the calculus course.
import math
r = 10 # radius in cm
theta = 1.2 # radians
print("arc length :", r * theta, "cm")
print("sector area:", 0.5 * r**2 * theta, "cm²")
# small-angle check: sin x ≈ x only in radians
for x in [0.1, 0.01]:
print(f"sin({x}) = {math.sin(x):.8f}")
print(f"sin of 0.1 'degrees' read as radians would be wrong: sin(0.1°) = {math.sin(math.radians(0.1)):.8f}")arc length : 12.0 cm
sector area: 60.0 cm²
sin(0.1) = 0.09983342
sin(0.01) = 0.00999983
sin of 0.1 'degrees' read as radians would be wrong: sin(0.1°) = 0.00174533
Coterminal angles and reference angles
Angles that differ by a whole number of turns end at the same terminal side; they are coterminal. 30°, 390° and −330° all point the same way. To bring any angle into the range , take it modulo . Python's % already returns a non-negative result for a positive divisor, which is exactly what you want:
The reference angle is the acute angle between the terminal side and the x-axis. For 150° it is 30°, for 225° it is 45°. Reference angles let you reduce every angle to the first quadrant, which the unit circle lesson uses heavily.
In software
- Every math library uses radians.
math.sin,numpy.sin, JavaScript'sMath.sin, C'ssin, GLSL'ssinall expect radians. Passing degrees is one of the most common bugs in game and graphics code:math.sin(90)is about 0.894, not 1. - Engines often show degrees. Unity's inspector, CSS
rotate(45deg)and most UI angle fields use degrees for humans, and convert internally. Keep one unit in your code (radians) and convert only at the edges: input fields and display. Naming helps:angle_rad,heading_deg. - Wrapping headings. A spinning object accumulates a huge angle; wrap it with
% (2 * math.pi)so values stay small and comparisons work. The game math radians lesson covers more patterns.
import math
print("math.sin(90) =", round(math.sin(90), 6), " # bug: 90 radians")
print("math.sin(math.radians(90)) =", math.sin(math.radians(90)))
heading = 0.0
for _ in range(25): # spin by 100° per frame for 25 frames
heading += math.radians(100)
print("raw heading :", round(heading, 4), "rad")
print("wrapped :", round(heading % (2 * math.pi), 4), "rad =",
round(math.degrees(heading % (2 * math.pi)), 2), "°")math.sin(90) = 0.893997 # bug: 90 radians
math.sin(math.radians(90)) = 1.0
raw heading : 43.6332 rad
wrapped : 5.9341 rad = 340.0 °
, so the wrapped heading is right.
Exercises
Exercise 1: Convert
Convert 210° and −45° to radians (exact, in terms of ), and and 3 rad to degrees.
Answer
, , , .
Solution
Exercise 2: Arc and sector
A pizza has radius 18 cm. A slice has a central angle of 40°. Find the length of its crust edge and its area.
Answer
(exactly ), (exactly ).
Solution
import math
theta = math.radians(40)
print(round(18 * theta, 3), round(0.5 * 18**2 * theta, 3))12.566 113.097
Exercise 3: Coterminal and reference angles
Find the angle in coterminal with 1000°, and with −250°. Give the reference angle of each.
Answer
, reference angle 80°. , reference angle 70°.
Solution
print(1000 % 360, -250 % 360)280 110
Exercise 4: A wheel's speed
A bike wheel of radius 0.35 m turns at 4 revolutions per second. Find its angular speed in rad/s and the bike's speed in m/s and km/h.
Answer
, .
Solution
import math
w = 4 * 2 * math.pi
v = 0.35 * w
print(round(w, 3), round(v, 3), round(v * 3.6, 2))25.133 8.796 31.67
Exercise 5: Shortest turn
A turret faces 350° and must turn to face 20°. Write shortest_turn(a, b) (degrees) that returns the signed turn in that gets from to , and test it on (350, 20) and (20, 350).
Answer
shortest_turn(350, 20) = 30 and shortest_turn(20, 350) = −30.
Solution
Take the difference modulo 360 to get a value in , then subtract 360 if it is above 180.
def shortest_turn(a, b):
d = (b - a) % 360
return d - 360 if d > 180 else d
print(shortest_turn(350, 20), shortest_turn(20, 350), shortest_turn(0, 180))30 -30 180
Test yourself
How many radians is 120°?
What does math.sin(30) compute in Python?
- The sine of 30 radians
- An error, because 30 is not in radians
A circle has radius 5. What is the arc length cut out by an angle of 2 radians?
- 2.5
- 7
- 10