Triangulation of monotone polygons (such as this one, which is monotone with respect to the vertical) can be performed in linear time using a "greedy" algorithm.
First the vertices are sorted by y-coordinate (here the horizontal lines drawn through the vertices show the sorted order.) The polygon is divided into two chains that meet at the vertices of largest and smallest y-coordinate. Here the right chain is white and the left chain is light blue. Starting from the bottom vertex, each vertex v(i) is evaluated and falls into one of the following categories:
- Case 1: v(i) is on the right chain and v(i-1) is on the left chain, or vice cersa. In this case the diangonal v(i-1)v(i) can be drawn. Vertices in this category, and the resulting diagonals, are drawn in red.
- Case 2: v(i) and v(i-1) are on the same chain. Let uv(i-1) be the last diagonal or side from v(i-1), if it exists. If uv(i-1)v(i) is convex, then the diagonal uv(i) can be drawn. Vertices in this category, and the resulting vertices, are drawn in green.
- Case 3: v(i) and v(i-1) are on the same chain, and uv(i-1)v(i) is not convex. In this case a diagonal cannot be drawn. The vertex v(i) would be pushed into a stack, and the program would go on to the next vertex v(i+1). Vertices that fall into this category are drawn in black.
Created with Cinderella
Return to the main page