earclip_rgl: Ear clipping triangulation

Description Usage Details Author(s) Examples

Description

Ear clipping is a relatively cheap method for constrained triangulation of polygons.

Usage

1
2
earclip_rgl(x, y = NULL, z = NULL, random = TRUE, plot = FALSE,
  partial = NA)

Details

Originally this code was published in the 'rgl' package, and written by Duncan Murdoch. The code from rgl 0.99.9 was copied on 2018-01-22.

Author(s)

Duncan Murdoch, in the rgl package

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
data("minimal_mesh", package = "silicate")
rbind_na <- function(x) {
## the inner head-1 is to remove the final closing/start point from simple features
head(do.call(rbind, lapply(x, function(a) rbind(head(a, -1), NA))), -1)
}
strip_sf <- function(x) {
  lapply(unlist(lapply(unclass(x), unclass), recursive = FALSE), rbind_na)
}
x <- strip_sf(minimal_mesh$geom)
lapply(x, earclip_rgl)
#ncsf <- sf::read_sf(system.file("shape/nc.shp", package="sf"))
#x <- strip_sf(ncsf$geometry)
#lapply(x, earclip_rgl)
## ## 20s in rgl, 14s with col/rowSums
#rbenchmark::benchmark(lapply(x[1:12], earclip_rgl), replications = 40)

mdsumner/earclip.rgl documentation built on May 4, 2019, 10:55 a.m.