a triangulation
Computers are wonderful at handling triangles and clumsy with everything else. A triangle is the simplest flat shape — three points, always lying in one plane, always convex — so to make a complicated shape computable, the first move is almost always to cut it up into triangles. Triangulation is exactly that: dividing a polygon, a surface, or a set of points into a collection of non-overlapping triangles that fit together edge to edge and cover the whole region.
For a simple polygon (one whose boundary does not cross itself), triangulating means slicing it into triangles using only diagonals — straight lines between two corners that stay inside the polygon — so that no two triangles overlap and together they fill the polygon. A neat fact pins down the count: a simple polygon with n vertices ALWAYS triangulates into exactly n - 2 triangles, no matter how it is done, using n - 3 diagonals. The simplest algorithm is 'ear-clipping': an ear is a triangle formed by three consecutive vertices that lies wholly inside the polygon; repeatedly snip off an ear, reducing the polygon by one vertex each time, until only a triangle remains. The two-ears theorem guarantees every simple polygon (with at least four vertices) has at least two ears, so ear-clipping never gets stuck. Smarter methods triangulate a simple polygon in time proportional to n, and a point set in n log n.
Triangulation underlies an enormous amount of practical computing: every 3D model in a video game or film is a mesh of triangles; finite-element engineering, terrain rendering, the famous art-gallery theorem on guard placement, and area computation all begin by triangulating. A few honest points. First, a region usually has MANY valid triangulations — the count of triangles is fixed at n - 2, but which diagonals you pick is not, and different choices have very different quality (this is exactly where the Delaunay triangulation earns its keep, choosing the fat-triangle option). Second, polygons with HOLES, or non-planar surfaces, need more careful definitions and algorithms; the clean n - 2 rule is specifically for a simple polygon without holes.
Triangulate a convex pentagon (n = 5). The formula promises n - 2 = 3 triangles using n - 3 = 2 diagonals. Pick one vertex, say A, and draw diagonals from it to the two non-adjacent vertices: this 'fan' splits the pentagon into 3 triangles. A different scheme, say ear-clipping from a different corner, gives a different set of 3 triangles — but always exactly 3, confirming the count is fixed even though the choice is not.
The triangle count n - 2 is fixed; which diagonals achieve it is a free, quality-determining choice.
The tidy n - 2 triangle count holds for a SIMPLE polygon without holes. Add a hole, or self-intersecting edges, and that formula no longer applies — those cases need their own treatment.