Triangles, Angles, and the Pythagorean Theorem
Pillar: SHAPE — "The shape of a triangle encodes all its measurements."
What Is an Angle?
An angle measures the amount of rotation between two rays that share a common endpoint (the vertex). Angles are measured in degrees (\(^\circ\)) or radians. One full rotation is \(360^\circ\) (or \(2\pi\) radians).
Angles fall into five categories:
| Type | Measure | Example |
|---|---|---|
| Acute | \(0^\circ < \theta < 90^\circ\) | \(45^\circ\) |
| Right | \(\theta = 90^\circ\) | corner of a square |
| Obtuse | \(90^\circ < \theta < 180^\circ\) | \(120^\circ\) |
| Straight | \(\theta = 180^\circ\) | a flat line |
| Reflex | \(180^\circ < \theta < 360^\circ\) | \(270^\circ\) |
These categories show up everywhere in problem constraints. When a problem says "convex polygon," it means every interior angle is less than \(180^\circ\) — no reflex angles allowed.
Angle Relationships
Three relationships you need immediately:
Complementary angles add to \(90^\circ\). If one angle is \(35^\circ\), its complement is \(55^\circ\).
Supplementary angles add to \(180^\circ\). If one angle is \(110^\circ\), its supplement is \(70^\circ\).
Vertical angles are the pairs of opposite angles formed when two lines cross. They are always equal.
When lines \(\ell_1\) and \(\ell_2\) intersect, they form four angles. The angles across from each other are vertical and therefore equal. If one is \(40^\circ\), the one across is \(40^\circ\), and the two adjacent ones are each \(140^\circ\).
Parallel Lines and a Transversal
When a line (the transversal) crosses two parallel lines, it creates eight angles. The relationships between them are the workhorse of angle-chasing problems.
Label the parallel lines \(\ell_1\) and \(\ell_2\), with transversal \(t\) crossing both. At each intersection you get four angles. The key pairs:
| Relationship | Position | Rule |
|---|---|---|
| Corresponding | Same position at each intersection | Equal |
| Alternate interior | Opposite sides of \(t\), between \(\ell_1\) and \(\ell_2\) | Equal |
| Alternate exterior | Opposite sides of \(t\), outside \(\ell_1\) and \(\ell_2\) | Equal |
| Co-interior (same-side interior) | Same side of \(t\), between \(\ell_1\) and \(\ell_2\) | Sum to \(180^\circ\) |
Worked example. A transversal crosses two parallel lines. One of the angles at the first intersection is \(65^\circ\). Find all eight angles.
At the first intersection: the four angles are \(65^\circ\), \(115^\circ\), \(65^\circ\), \(115^\circ\) (vertical pairs). At the second intersection: corresponding angles match, so the same four values appear. All eight angles are determined by just one measurement.
Triangle Angle Sum
The angles inside any triangle sum to exactly \(180^\circ\):
Why? Draw a line through vertex \(A\) parallel to side \(BC\). The alternate interior angles at \(A\) equal \(\angle B\) and \(\angle C\). These two angles plus \(\angle A\) sit on a straight line, so they sum to \(180^\circ\).
This is the single most-used fact in geometry. If you know two angles of a triangle, the third is forced:
Exterior angle theorem. An exterior angle of a triangle (formed by extending one side) equals the sum of the two non-adjacent interior angles. If you extend side \(BC\) past \(C\), the exterior angle at \(C\) equals \(\angle A + \angle B\).
Triangle Classification
Triangles are classified two ways: by sides and by angles.
By sides:
| Type | Sides | Angles |
|---|---|---|
| Scalene | All different | All different |
| Isosceles | Two equal | Two equal (base angles) |
| Equilateral | All equal | All \(60^\circ\) |
By angles:
| Type | Condition |
|---|---|
| Acute | All angles \(< 90^\circ\) |
| Right | One angle \(= 90^\circ\) |
| Obtuse | One angle \(> 90^\circ\) |
An equilateral triangle is always acute. An isosceles triangle can be acute, right, or obtuse. In competitive programming, the triangle inequality (\(a + b > c\) for all permutations of sides) is the standard check for whether three lengths can form a triangle at all.
The Pythagorean Theorem
For a right triangle with legs \(a\) and \(b\) and hypotenuse \(c\) (the side opposite the right angle):
Proof sketch (area argument). Arrange four copies of the right triangle inside a large square of side \(a + b\). The four hypotenuses form an inner square of side \(c\). The area of the large square equals the area of the inner square plus the four triangles:
Expand: \(a^2 + 2ab + b^2 = c^2 + 2ab\). Cancel \(2ab\): \(a^2 + b^2 = c^2\).
Example. A right triangle has legs \(5\) and \(12\). Find the hypotenuse.
In code, use sqrt(a*a + b*b) or avoid floating-point entirely by comparing squared values:
Converse of the Pythagorean Theorem
The converse is equally useful: given three sides \(a\), \(b\), \(c\) with \(c\) the largest, the triangle is:
| Condition | Triangle type |
|---|---|
| \(a^2 + b^2 = c^2\) | Right |
| \(a^2 + b^2 > c^2\) | Acute |
| \(a^2 + b^2 < c^2\) | Obtuse |
This is the standard way to classify a triangle by its angles in code — no need to compute actual angles.
bool isRight(int a, int b, int c) {
if (a > c) swap(a, c);
if (b > c) swap(b, c);
return (long long)a * a + (long long)b * b == (long long)c * c;
}
Note the cast to long long — squaring integers can overflow int when sides are large.
Special Right Triangles
Two right triangles appear so often that their ratios are worth memorizing.
45-45-90 Triangle
An isosceles right triangle. The legs are equal, and the hypotenuse is \(\sqrt{2}\) times a leg.
If each leg is \(a\), the hypotenuse is \(a\sqrt{2}\). This triangle is half of a square cut along its diagonal.
30-60-90 Triangle
Half of an equilateral triangle cut along an altitude.
The side opposite \(30^\circ\) is the shortest (call it \(a\)). The side opposite \(60^\circ\) is \(a\sqrt{3}\). The hypotenuse (opposite \(90^\circ\)) is \(2a\).
Example. An equilateral triangle has side length \(10\). Find its height.
Cut it in half. You get a 30-60-90 triangle with hypotenuse \(10\) and short leg \(5\). The height is the long leg:
These ratios let you avoid sqrt calls entirely when the geometry guarantees a special triangle. In CP, recognizing a 30-60-90 or 45-45-90 saves time and avoids floating-point error.
Pythagorean Triples
A Pythagorean triple is three positive integers \((a, b, c)\) with \(a^2 + b^2 = c^2\). The most common:
| \(a\) | \(b\) | \(c\) |
|---|---|---|
| 3 | 4 | 5 |
| 5 | 12 | 13 |
| 8 | 15 | 17 |
| 7 | 24 | 25 |
Any multiple of a triple is also a triple: \((6, 8, 10) = 2 \times (3, 4, 5)\).
Generating all primitive triples. A triple is primitive if \(\gcd(a, b, c) = 1\). Every primitive triple can be written as:
where \(m > n > 0\), \(\gcd(m, n) = 1\), and \(m - n\) is odd.
CP connection. Problems involving lattice points on circles ("how many integer points lie on \(x^2 + y^2 = r^2\)?") reduce to counting representations as sums of two squares, which connects directly to Pythagorean triples and number theory.
Worked Examples
Example 1: Finding Missing Angles
In triangle \(ABC\), \(\angle A = 50^\circ\) and \(\angle B = 70^\circ\). Find \(\angle C\) and classify the triangle.
All angles are less than \(90^\circ\), so the triangle is acute. All angles are different, so by the side criterion it's scalene (different angles imply different opposite sides).
Example 2: Converse Application
Triangle with sides \(7\), \(10\), \(12\). Is it acute, right, or obtuse?
Largest side is \(12\). Check: \(7^2 + 10^2 = 49 + 100 = 149\). Compare to \(12^2 = 144\).
Since \(149 > 144\), we have \(a^2 + b^2 > c^2\), so the triangle is acute.
Example 3: 30-60-90 in Action
A ramp makes a \(30^\circ\) angle with the ground and rises \(3\) meters vertically. How long is the ramp?
The vertical rise is opposite the \(30^\circ\) angle, so it's the short leg. The ramp is the hypotenuse. In a 30-60-90 triangle, hypotenuse \(= 2 \times\) short leg:
Practice Problems
1. Two angles of a triangle are \(35^\circ\) and \(85^\circ\). Find the third angle and classify the triangle by angles.
2. A right triangle has hypotenuse \(25\) and one leg \(7\). Find the other leg.
3. Determine whether the triangle with sides \(9\), \(40\), \(41\) is right, acute, or obtuse.
4. An isosceles right triangle has hypotenuse \(10\sqrt{2}\). Find the length of each leg.
5. Find all Pythagorean triples with hypotenuse less than \(30\).
Answers
1. \(\angle C = 180^\circ - 35^\circ - 85^\circ = 60^\circ\). All angles are acute, so the triangle is acute.
2. \(b = \sqrt{25^2 - 7^2} = \sqrt{625 - 49} = \sqrt{576} = 24\).
3. \(9^2 + 40^2 = 81 + 1600 = 1681 = 41^2\). Since \(a^2 + b^2 = c^2\), it is a right triangle.
4. In a 45-45-90 triangle, hypotenuse \(= \text{leg} \times \sqrt{2}\). So leg \(= 10\sqrt{2} / \sqrt{2} = 10\).
5. Primitive triples: \((3,4,5)\), \((5,12,13)\), \((8,15,17)\), \((7,24,25)\), \((20,21,29)\). Multiples with \(c < 30\): \((6,8,10)\), \((9,12,15)\), \((12,16,20)\), \((15,20,25)\), \((10,24,26)\).
Quick Recap
- Five angle types: acute, right, obtuse, straight, reflex.
- Complementary (\(90^\circ\)), supplementary (\(180^\circ\)), vertical (equal).
- Parallel lines + transversal: corresponding and alternate interior angles are equal; co-interior angles sum to \(180^\circ\).
- Triangle angle sum \(= 180^\circ\). Two angles determine the third.
- Classify by sides (scalene, isosceles, equilateral) or by angles (acute, right, obtuse).
- Pythagorean theorem: \(a^2 + b^2 = c^2\) for right triangles. The converse classifies triangles.
- Special triangles: \(1:1:\sqrt{2}\) (45-45-90) and \(1:\sqrt{3}:2\) (30-60-90).
- Pythagorean triples are generated by \(m^2 - n^2\), \(2mn\), \(m^2 + n^2\).