The goal of decido is to provide an R binding to the Mapbox library earcut.hpp for constrained polygon triangulation. Decido is aimed at package developers at the moment, there are not high-level classes or objects but the earcut functionality can be easily used in higher-level tools or just used directly.
Ear cutting (or ear clipping) applies constrained triangulation by successively ‘cutting’ triangles from a polygon defined by path/s. Holes are supported, the earcut library works with single-island-with-holes polygons, analogous to the POLYGON type in simple features.
Install the released version from CRAN.
## install.packages("remotes") remotes::install_cran("decido")
You can install the development version from GitHub with the following code. You will need the set of development tools for building source packages with binary code.
## install.packages("devtools") devtools::install_github("hypertidy/decido", build_vignettes = TRUE)
This is a basic example of triangulating a single-ring polygon. The output is a vector of triplet indices defining each triangle.
Open the getting started vignette.
vignette("decido", package = "decido")
This is motivated by the topology aspirations of silicate. We need tools for decomposing shape data into primitives for analysis and visualization. Decomposition into graph types is already well supported and exercised, but triangulations of paths versus triangulations from edges are two key facilities needed for greater control.
This broader project is fairly well advanced in silicate which provides ear-cutting triangulations and enhanced with high-quality methods in hypertidy/anglr.
Ear clipping (or ear cutting) is also available in the rgl function
triangulate (implemented in R), and in the lawn function
INLA package has some kind of constraint-based triangulation, but I don’t yet know the details.
In comparison to path-based ear-clipping, other libraries ‘Triangle’ and ‘CGAL’ provide edge-based mostly Delaunay triangulation. The Triangle library is available in the R package RTriangle and for (some) R spatial formats in sfdct. Experimental implementations binding CGAL are in rcgal and laridae.
Do you know of others? Let me know! Triangulation is common across many R packages, but constrained algorithms are pretty rare (it’s hard). There are many Delaunay and other non-constrained implementations in many packages, and I’m compiling a list of those as well. OTOH there’s rgeos, sf, deldir, geometry, tripack, spatstat, akima, several mesh-related packages Rvcg, meshsimp, icosa, webglobe …
Please note that the decido project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.