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
The exterior angle rule follows from the angle sum: the exterior angle at is , which equals .
The Pythagorean theorem and its converse
In a right triangle with legs , and hypotenuse (the side opposite the right angle):
The converse lets you classify any triangle from its sides. Sort them so is the longest, then compare:
| Comparison | Triangle |
|---|---|
| right | |
| acute | |
| obtuse |
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° | |
| half an equilateral triangle | 30°, 60°, 90° |
They give exact values such as and in The Trigonometric Functions.
Area three ways
All three agree on the triangle with corners , , , whose base is 7 and height 5:
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,distand 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
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
Exercise 3: Possible third sides
Two sides of a triangle are 4 and 9. Which lengths are possible for the third side ?
Answer
Solution
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
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 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: .
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?
- Right
- Acute
- Obtuse
- Not a triangle
What are the side ratios of a 45-45-90 triangle?
Why do GPUs draw meshes as triangles?
- Triangles have the largest area
- Three points always lie in one plane and form a convex shape
- Triangles need no coordinates
- Squares cannot be drawn on screens