geometry25 min

Triangles

Triangle types, the Pythagorean theorem, and the triangle inequality

0/9Not Started

Why This Matters

The triangle is the simplest polygon and arguably the most important shape in all of geometry. Every polygon can be decomposed into triangles, which is why 3D graphics engines render the world entirely in triangles. Understanding triangles means understanding the fundamental unit of shape.

The Pythagorean theorem (a squared plus b squared equals c squared) is one of the most famous results in mathematics. It connects the sides of a right triangle and is the foundation of the distance formula, vector magnitude, and countless engineering calculations. Meanwhile, the triangle inequality tells you whether three lengths can even form a triangle at all -- a surprisingly useful check in computational geometry, network routing, and optimization.

Triangles also form the bridge between geometry and trigonometry. Once you understand how angles and side lengths relate in a triangle, you are ready for sine, cosine, and the entire world of trigonometric functions.

Define Terms

Visual Model

Triangle3 sides, 3 angles
By SidesSide length classification
By AnglesAngle classification
EquilateralAll sides equal
IsoscelesTwo sides equal
ScaleneNo sides equal
AcuteAll angles < 90
RightOne angle = 90
ObtuseOne angle > 90
Pythagorean Theorema^2 + b^2 = c^2
Triangle Inequalitya + b > c

The full process at a glance. Click Start tour to walk through each step.

Triangles are classified by sides (equilateral, isosceles, scalene) and by angles (acute, right, obtuse). Right triangles unlock the Pythagorean theorem.

Code Example

Code
// Check if three sides form a valid triangle
function isValidTriangle(a, b, c) {
  return a + b > c && a + c > b && b + c > a;
}
console.log(isValidTriangle(3, 4, 5));  // true
console.log(isValidTriangle(1, 2, 10)); // false

// Classify triangle by sides
function classifyBySides(a, b, c) {
  if (a === b && b === c) return "equilateral";
  if (a === b || b === c || a === c) return "isosceles";
  return "scalene";
}
console.log(classifyBySides(5, 5, 5));  // equilateral
console.log(classifyBySides(5, 5, 3));  // isosceles
console.log(classifyBySides(3, 4, 5));  // scalene

// Classify triangle by angles using side lengths
function classifyByAngles(a, b, c) {
  const sides = [a, b, c].sort((x, y) => x - y);
  const [s1, s2, s3] = sides;
  const sumSq = s1 ** 2 + s2 ** 2;
  if (Math.abs(sumSq - s3 ** 2) < 0.0001) return "right";
  if (sumSq > s3 ** 2) return "acute";
  return "obtuse";
}
console.log(classifyByAngles(3, 4, 5));   // right
console.log(classifyByAngles(5, 6, 7));   // acute
console.log(classifyByAngles(3, 4, 6));   // obtuse

// Pythagorean theorem: find hypotenuse
function hypotenuse(a, b) {
  return Math.sqrt(a ** 2 + b ** 2);
}
console.log(hypotenuse(3, 4)); // 5

Interactive Experiment

Try these exercises:

  • Test whether the sides (2, 3, 10) can form a triangle. Why or why not?
  • Find the hypotenuse of a right triangle with legs 5 and 12. Verify with the Pythagorean theorem.
  • Classify the triangle with sides (7, 7, 7) by both sides and angles. What do you notice?
  • Given sides (8, 15, 17), determine if this is a right triangle. Check whether 8 squared plus 15 squared equals 17 squared.
  • What is the smallest integer hypotenuse for a right triangle with legs 6 and 8?

Quick Quiz

Coding Challenge

Triangle Validator and Classifier

Write a function called `classifyTriangle` that takes three side lengths (positive numbers) and returns a string. If the sides do not form a valid triangle (triangle inequality fails), return 'invalid'. Otherwise, return the classification by sides: 'equilateral', 'isosceles', or 'scalene'.

Loading editor...

Real-World Usage

Triangles are everywhere in computing and engineering:

  • 3D graphics and game engines: GPUs render all 3D scenes as millions of triangles. Meshes of triangles approximate curved surfaces, and the Pythagorean theorem computes distances in 3D space.
  • Structural engineering: Triangles are the strongest shape for trusses and bridges because they cannot deform without changing side lengths, unlike rectangles.
  • Navigation and surveying: Triangulation uses known distances and angles to compute unknown positions, from GPS satellites to land surveying.
  • Machine learning: Distance metrics (Euclidean distance) use the Pythagorean theorem, and the triangle inequality is used to prune nearest-neighbor searches.
  • Network optimization: The triangle inequality ensures that the direct route between two points is never longer than a detour through a third point, a property used in routing algorithms.

Connections