A minimum polygon data set, with a small concavity and a single hole. The data is in 'xy.coords' form, with two columns for 'x_' and 'y_' values, with 'NA' rows separating separate polygon paths. (All but the first path are holes).
plot(minpoly)polypath(minpoly, col = "grey", rule = "evenodd")lines(na.omit(minpoly)) ## see the connection in the sequencenas <- which(is.na(minpoly$x_)) ## this is the "indicate where holes start" convention hole_index <- nas - (seq_along(nas) - 1) minpoly_xy <- na.omit(minpoly) tri_index <- earcut(minpoly_xy, hole_index) rearcut:::plot_tri(minpoly_xy$x_, minpoly_xy$y_, tri_index)rearcut:::plot_tri(minpoly_xy$x_, minpoly_xy$y_, tri_index, col = "firebrick")