TExcelTAD

Triangles

The triangle is the simplest polygon and the most useful one: every polygon can be cut into triangles, every 3D model on a screen is drawn as triangles, and trigonometry is built on them. This lesson covers how triangles are classified, their angle and side rules, the Pythagorean theorem, and three ways to find their area.

Classifying triangles

By sides Meaning By angles Meaning
equilateral all three sides equal acute all angles below 90°
isosceles at least two sides equal right one angle exactly 90°
scalene no sides equal obtuse one angle above 90°

An equilateral triangle has three 60° angles. In an isosceles triangle the angles opposite the equal sides (the base angles) are equal; that is the isosceles triangle theorem, proved in Geometric Proofs.

Rules every triangle follows

angle sum:A+B+C=180∘exterior angle:an exterior angle=the sum of the two remote interior anglestriangle inequality:each side<the sum of the other twolargest sideis opposite the largest angle\begin{aligned} \text{angle sum:} &\quad A + B + C = 180^\circ \\ \text{exterior angle:} &\quad \text{an exterior angle} = \text{the sum of the two remote interior angles} \\ \text{triangle inequality:} &\quad \text{each side} < \text{the sum of the other two} \\ \text{largest side} &\quad \text{is opposite the largest angle} \end{aligned}

The exterior angle rule follows from the angle sum: the exterior angle at CC is 180∘−C180^\circ - C, which equals A+BA + B.

The Pythagorean theorem and its converse

In a right triangle with legs aa, bb and hypotenuse cc (the side opposite the right angle):

a2+b2=c2a^2 + b^2 = c^2

The converse lets you classify any triangle from its sides. Sort them so cc is the longest, then compare:

Comparison Triangle
a2+b2=c2a^2 + b^2 = c^2 right
a2+b2>c2a^2 + b^2 > c^2 acute
a2+b2<c2a^2 + b^2 < c^2 obtuse
python · try it yourself
def classify(a, b, c):
    a, b, c = sorted((a, b, c))
    if a + b <= c:
        return "not a triangle"
    sides = "equilateral" if a == c else "isosceles" if a == b or b == c else "scalene"
    lhs, rhs = a * a + b * b, c * c
    angles = "right" if lhs == rhs else "acute" if lhs > rhs else "obtuse"
    return f"{angles} {sides}"

for t in [(3, 4, 5), (2, 2, 3), (5, 5, 5), (4, 5, 6), (1, 2, 3), (5, 12, 13)]:
    print(t, "→", classify(*t))
(3, 4, 5) → right scalene
(2, 2, 3) → obtuse isosceles
(5, 5, 5) → acute equilateral
(4, 5, 6) → acute scalene
(1, 2, 3) → not a triangle
(5, 12, 13) → right scalene

(1, 2, 3) fails the triangle inequality with equality: the three "sides" lie flat on one line (a degenerate triangle). Whole-number solutions such as 3-4-5 and 5-12-13 are Pythagorean triples. With floats, never test lhs == rhs exactly; compare with a small tolerance as in Floating Point.

Special right triangles

Two right triangles come up so often that their side ratios are worth memorising:

Triangle Angles Sides (short : long : hypotenuse)
half a square 45°, 45°, 90° 1:1:21 : 1 : \sqrt{2}
half an equilateral triangle 30°, 60°, 90° 1:3:21 : \sqrt{3} : 2

They give exact values such as sin⁡30∘=12\sin 30^\circ = \frac{1}{2} and cos⁡45∘=2/2\cos 45^\circ = \sqrt{2}/2 in The Trigonometric Functions.

Area three ways

base and height:A=12⋅b⋅hHeron (3 sides):s=(a+b+c)/2,A=s(s−a)(s−b)(s−c)coordinates:A=12⋅∣x1(y2−y3)+x2(y3−y1)+x3(y1−y2)∣\begin{aligned} \text{base and height:} &\quad A = \tfrac{1}{2} \cdot b \cdot h \\ \text{Heron (3 sides):} &\quad s = (a + b + c) / 2, \qquad A = \sqrt{s(s - a)(s - b)(s - c)} \\ \text{coordinates:} &\quad A = \tfrac{1}{2} \cdot \lvert x_1(y_2 - y_3) + x_2(y_3 - y_1) + x_3(y_1 - y_2) \rvert \end{aligned}

All three agree on the triangle with corners (0,0)(0, 0), (7,0)(7, 0), (2,5)(2, 5), whose base is 7 and height 5:

python · try it yourself
import math

P, Q, R = (0, 0), (7, 0), (2, 5)
a, b, c = math.dist(Q, R), math.dist(P, R), math.dist(P, Q)
s = (a + b + c) / 2
heron = math.sqrt(s * (s - a) * (s - b) * (s - c))
coords = abs(P[0] * (Q[1] - R[1]) + Q[0] * (R[1] - P[1]) + R[0] * (P[1] - Q[1])) / 2

print("½·b·h :", 0.5 * 7 * 5)
print("Heron :", round(heron, 10))
print("coords:", coords)
centroid = ((P[0] + Q[0] + R[0]) / 3, (P[1] + Q[1] + R[1]) / 3)
print("centroid:", tuple(round(v, 4) for v in centroid))
½·b·h : 17.5
Heron : 17.5
coords: 17.5
centroid: (3.0, 1.6667)

The centroid, the average of the three corners, is where the three medians (vertex to opposite midpoint) meet. It is the triangle's balance point. Other centres: the circumcentre (equal distance from all corners, centre of the circle through them) and the incentre (equal distance from all sides).

In software

  • Rendering: GPUs draw everything as triangles because three points always lie in one plane and a triangle is always convex. See Procedural Shapes and Meshes.
  • Ray tracing and picking: "did the click hit this triangle?" is Ray-Triangle Intersection.
  • Navigation meshes and terrain: maps are triangulated so a path finder can walk across them.
  • Distance checks: the Pythagorean theorem is behind every hypot, dist and vector length.

Exercises

Exercise 1: The missing angle

A triangle has angles 47° and 68°. Find the third angle and classify the triangle by its angles.

Answer

65°; acute.

Solution
C=180∘−47∘−68∘=65∘all three angles are below 90∘, so the triangle is acute\begin{aligned} &C = 180^\circ - 47^\circ - 68^\circ = 65^\circ \\ &\text{all three angles are below } 90^\circ\text{, so the triangle is acute} \end{aligned}

Exercise 2: Exterior angle

Two interior angles of a triangle are 40° and 75°. What is the exterior angle at the third vertex?

Answer

115°

Solution
exterior angle=sum of the two remote interior angles=40∘+75∘=115∘check: third angle=65∘, and 180∘−65∘=115∘\begin{aligned} &\text{exterior angle} = \text{sum of the two remote interior angles} = 40^\circ + 75^\circ = 115^\circ \\ &\text{check: third angle} = 65^\circ\text{, and } 180^\circ - 65^\circ = 115^\circ \end{aligned}

Exercise 3: Possible third sides

Two sides of a triangle are 4 and 9. Which lengths are possible for the third side xx?

Answer

5<x<135 < x < 13

Solution
x<4+9=139<4+x⇒x>54<9+x(always true)\begin{aligned} x &< 4 + 9 = 13 \\ 9 &< 4 + x \Rightarrow x > 5 \\ 4 &< 9 + x && \text{(always true)} \end{aligned}

Exercise 4: Heron's 13-14-15

Find the area of a triangle with sides 13, 14 and 15, by hand, then check in Python.

Answer

84

Solution
s=(13+14+15)/2=21A=21⋅8⋅7⋅6=7056=84\begin{aligned} s &= (13 + 14 + 15) / 2 = 21 \\ A &= \sqrt{21 \cdot 8 \cdot 7 \cdot 6} = \sqrt{7056} = 84 \end{aligned}
python · try it yourself
import math
s = (13 + 14 + 15) / 2
print(math.sqrt(s * (s - 13) * (s - 14) * (s - 15)))
84.0

Exercise 5: A 30-60-90 ladder

A ladder 10 m long leans against a wall and makes a 60° angle with the ground. How high up the wall does it reach, and how far is its foot from the wall?

Answer

Height 53≈8.6605\sqrt{3} \approx 8.660 m, foot 5 m from the wall.

Solution

The ladder is the hypotenuse (2 parts = 10 m, so 1 part = 5 m). The side opposite the 30° angle (at the top) is the short one, the distance along the ground: 5 m. The side opposite the 60° angle is the height: 535\sqrt{3}.

python · try it yourself
import math
print(round(5 * math.sqrt(3), 3), round(math.hypot(5, 5 * math.sqrt(3)), 3))
8.66 10.0

Test yourself

A triangle has sides 6, 7 and 10. What kind is it?

  1. Right
  2. Acute
  3. Obtuse
  4. Not a triangle

What are the side ratios of a 45-45-90 triangle?

  1. 1:1:21 : 1 : \sqrt{2}
  2. 1:3:21 : \sqrt{3} : 2
  3. 1:2:51 : 2 : \sqrt{5}
  4. 1:1:21 : 1 : 2

Why do GPUs draw meshes as triangles?

  1. Triangles have the largest area
  2. Three points always lie in one plane and form a convex shape
  3. Triangles need no coordinates
  4. Squares cannot be drawn on screens