TExcelTAD

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 AA
Line straight, endless in both directions line ABAB, or AB↔\overleftrightarrow{AB}
Ray starts at a point and goes on forever in one direction ray AB→\overrightarrow{AB} (starts at AA)
Segment the part of a line between two endpoints AB‾\overline{AB}, with length ∣AB∣\lvert AB \rvert
Plane a flat surface without edges plane PP

Two distinct points fix exactly one line. Two lines in a plane either intersect in one point or are parallel (never meet, written AB∥CDAB \parallel CD). Lines that meet at a right angle are perpendicular (AB⊥CDAB \perp CD).

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 aa and bb side by side, then a+b=180∘a + b = 180^\circ and b+c=180∘b + c = 180^\circ, so a=ca = c.)
python · try it yourself
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 xx and its supplement 180∘−x180^\circ - x.

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):

python · try it yourself
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 formula
71.565
90.0
0.0
71.565

The last line checks the slope formula tan⁡θ=∣m1−m21+m1m2∣\tan\theta = \left\lvert \frac{m_1 - m_2}{1 + m_1 m_2} \right\rvert. It fails for perpendicular lines because then m1m2=−1m_1 m_2 = -1 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:

python · try it yourself
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
complement=90∘−38∘=52∘supplement=180∘−38∘=142∘\begin{aligned} \text{complement} &= 90^\circ - 38^\circ = 52^\circ \\ \text{supplement} &= 180^\circ - 38^\circ = 142^\circ \end{aligned}

Exercise 2: Vertical angles

Two lines cross. One angle measures (3x+10)∘(3x + 10)^\circ and the angle opposite it measures (5x−30)∘(5x - 30)^\circ. Find xx and all four angles.

Answer

x=20x = 20; the angles are 70°, 110°, 70°, 110°.

Solution
vertical angles are equal:3x+10=5x−3040=2x⇒x=20angle=3⋅20+10=70∘;its neighbours=180∘−70∘=110∘\begin{aligned} \text{vertical angles are equal:} &\quad 3x + 10 = 5x - 30 \\ &\quad 40 = 2x \Rightarrow x = 20 \\ \text{angle} = 3 \cdot 20 + 10 = 70^\circ; &\quad \text{its neighbours} = 180^\circ - 70^\circ = 110^\circ \end{aligned}

Exercise 3: Co-interior angles

A transversal crosses two parallel lines. Two co-interior angles measure (2x+15)∘(2x + 15)^\circ and (x+30)∘(x + 30)^\circ. Find both.

Answer

105° and 75°.

Solution
co-interior angles add to 180∘:(2x+15)+(x+30)=1803x+45=180⇒x=452⋅45+15=105∘,45+30=75∘(check: 105+75=180)\begin{aligned} \text{co-interior angles add to } 180^\circ{:} &\quad (2x + 15) + (x + 30) = 180 \\ &\quad 3x + 45 = 180 \Rightarrow x = 45 \\ 2 \cdot 45 + 15 = 105^\circ, &\quad 45 + 30 = 75^\circ \quad (\text{check: } 105 + 75 = 180) \end{aligned}

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

(45−300+180) mod 360−180=(−75 mod 360)−180=285−180=105(45 - 300 + 180) \bmod 360 - 180 = (-75 \bmod 360) - 180 = 285 - 180 = 105. Going counter-clockwise from 300° by 105° passes 360° and lands on 45°.

python · try it yourself
print((45 - 300 + 180) % 360 - 180)
105

Test yourself

Two lines cross and one angle is 64°. What is the angle vertically opposite it?

  1. 116°
  2. 26°
  3. 64°
  4. 296°

A transversal cuts two parallel lines. Which pair of angles adds up to 180°?

  1. Corresponding angles
  2. Alternate interior angles
  3. Vertical angles
  4. Co-interior (same-side interior) angles

What does (target - current + 180) % 360 - 180 give for current = 350, target = 20?

  1. 30
  2. −330
  3. 330
  4. −30