Lines and Angles
Points, lines and angles are the alphabet of geometry. This lesson fixes the vocabulary, the angle facts you will use in every later proof, and the rules for angles formed when a line crosses two parallel lines, then shows how code measures and wraps angles.
Points, lines, rays and segments
| Object | Description | Notation |
|---|---|---|
| Point | a location with no size | |
| Line | straight, endless in both directions | line , or |
| Ray | starts at a point and goes on forever in one direction | ray (starts at ) |
| Segment | the part of a line between two endpoints | , with length |
| Plane | a flat surface without edges | plane |
Two distinct points fix exactly one line. Two lines in a plane either intersect in one point or are parallel (never meet, written ). Lines that meet at a right angle are perpendicular ().
Kinds of angles
An angle is formed by two rays with a common endpoint, the vertex. We measure it in degrees here (radians come in Angles and Radians).
| Name | Size |
|---|---|
| acute | between 0° and 90° |
| right | exactly 90° |
| obtuse | between 90° and 180° |
| straight | exactly 180° |
| reflex | between 180° and 360° |
Pairs of angles have names too:
- Complementary angles add up to 90°. Supplementary angles add up to 180°.
- Angles side by side on a straight line form a linear pair and are supplementary.
- When two lines cross, the opposite angles are vertical angles, and vertical angles are equal. (If the angles are and side by side, then and , so .)
def classify(deg):
if deg <= 0 or deg >= 360:
return "not a single angle"
if deg < 90:
return "acute"
if deg == 90:
return "right"
if deg < 180:
return "obtuse"
if deg == 180:
return "straight"
return "reflex"
for a in [35, 90, 127, 180, 250]:
comp = 90 - a if a < 90 else None
print(f"{a:3}° {classify(a):9} complement: {comp} supplement: {180 - a if a < 180 else None}") 35° acute complement: 55 supplement: 145
90° right complement: None supplement: 90
127° obtuse complement: None supplement: 53
180° straight complement: None supplement: None
250° reflex complement: None supplement: None
Parallel lines and a transversal
A line that crosses two parallel lines is a transversal. It creates eight angles, but only two different sizes: an angle and its supplement .
| Pair | Where they sit | Relationship |
|---|---|---|
| corresponding | same position at each crossing | equal |
| alternate interior | between the parallels, opposite sides of the transversal | equal |
| alternate exterior | outside the parallels, opposite sides | equal |
| co-interior (same-side interior) | between the parallels, same side | add to 180° |
The converse also holds: if corresponding angles are equal, the lines are parallel. That is how you prove two lines are parallel in Geometric Proofs, and the alternate-interior rule is the key step in proving that a triangle's angles add up to 180°.
The angle between two lines
In coordinates a line has a direction, and its angle with the x-axis is atan2(dy, dx). The angle between two lines is the difference of their directions, folded into the range 0° to 90° (lines, unlike rays, have no arrow):
import math
def line_angle(d1, d2):
a = math.degrees(math.atan2(d1[1], d1[0]) - math.atan2(d2[1], d2[0]))
a = abs(a) % 180 # lines repeat every 180°
return min(a, 180 - a) # report the acute one
print(round(line_angle((1, 2), (1, -1)), 3)) # y = 2x and y = −x
print(round(line_angle((1, 0), (0, 5)), 3)) # x-axis and y-axis
print(round(line_angle((2, 1), (4, 2)), 3)) # parallel directions
m1, m2 = 2, -1
print(round(math.degrees(math.atan(abs((m1 - m2) / (1 + m1 * m2)))), 3)) # slope formula71.565
90.0
0.0
71.565
The last line checks the slope formula . It fails for perpendicular lines because then and the denominator is zero, which is one reason code prefers direction vectors.
In software: headings and wrapping
Games and robots store a heading angle. Angles wrap around: 370° is the same direction as 10°, and turning from 350° to 20° should be a 30° turn to the left, not 330° to the right. Two one-liners handle this:
def wrap360(a):
return a % 360 # Python's % is never negative for a positive divisor
def shortest_turn(current, target):
return (target - current + 180) % 360 - 180 # result in [−180, 180)
print(wrap360(370), wrap360(-90))
print(shortest_turn(350, 20))
print(shortest_turn(10, 300))
print(shortest_turn(0, 180))10 270
30
-70
-180
A positive result means turn counter-clockwise, negative means clockwise. In C, Java or JavaScript the % operator can return negatives, so you add 360 first. See also Angle Between Vectors.
Exercises
Exercise 1: Complement and supplement
Find the complement and the supplement of 38°.
Answer
Complement 52°, supplement 142°.
Solution
Exercise 2: Vertical angles
Two lines cross. One angle measures and the angle opposite it measures . Find and all four angles.
Answer
; the angles are 70°, 110°, 70°, 110°.
Solution
Exercise 3: Co-interior angles
A transversal crosses two parallel lines. Two co-interior angles measure and . Find both.
Answer
105° and 75°.
Solution
Exercise 4: Turning a turret
A turret faces 300° and must face 45°. Use shortest_turn to find the turn, and say whether it is clockwise or counter-clockwise.
Answer
105, counter-clockwise.
Solution
. Going counter-clockwise from 300° by 105° passes 360° and lands on 45°.
print((45 - 300 + 180) % 360 - 180)105
Test yourself
Two lines cross and one angle is 64°. What is the angle vertically opposite it?
- 116°
- 26°
- 64°
- 296°
A transversal cuts two parallel lines. Which pair of angles adds up to 180°?
- Corresponding angles
- Alternate interior angles
- Vertical angles
- Co-interior (same-side interior) angles
What does (target - current + 180) % 360 - 180 give for current = 350, target = 20?
- 30
- −330
- 330
- −30