triangulate(x, y = NULL, random = TRUE, plot = FALSE, partial = NA)
xy.coords
."nextvert"
with one entry per vertex, giving the index of the next
vertex to proceed counter-clockwise around outer
polygon boundaries, clockwise around inner boundaries.NA
values in x
or y
.
Each of these pieces should be a simple, non-self-intersecting
polygon, separate from the other pieces.
(Though some minor exceptions to this rule may work, none
are guaranteed). The nesting of these pieces is determined.
The extrude3d
for a solid extrusion of a polygon, polygon3d
for
a flat display; both use triangulate
.theta <- seq(0, 2*pi, len=25)[-25]
theta <- c(theta, NA, theta, NA, theta, NA, theta, NA, theta)
r <- c(rep(1.5, 24), NA, rep(0.5, 24), NA, rep(0.5, 24), NA, rep(0.3, 24), NA, rep(0.1, 24))
dx <- c(rep(0, 24), NA, rep(0.6, 24), NA, rep(-0.6, 24), NA, rep(-0.6, 24), NA, rep(-0.6, 24))
x <- r*cos(theta) + dx
y <- r*sin(theta)
plot(x,y,type="n")
polygon(x,y)
triangulate(x, y, plot=TRUE)
open3d()
polygon3d(x, y, x - y, col = "red")
Run the code above in your browser using DataLab