set.seed(42)
x <- runif(60)
y <- runif(60)
dxy <- deldir(x,y,rw=c(0,1,0,1))
nbrs <- getNbrs(dxy,interior=c(0.2,0.8,0.2,0.8))
nbrs[["14"]] # Correct.
nbrs[[14]] # Incorrect.
names(nbrs)[14] # The result is 42.
# Thus nbrs[[14]] actually gives the Delaunay neighbours of point 42.
# Demonstrate that neighbours can have discontiguous clipped tiles.
if(require(polyclip)) {
x <- c(0.38,0.44,0.04,0.97,0.43,0.96,0.89,0.64,0.97,0.62,0.33,0.35,
0.40,0.78,0.04,0.75,0.68,0.17,0.26,0.51)
y <- c(0.68,0.98,0.76,0.57,0.85,0.19,0.27,0.83,0.69,0.24,0.04,0.14,
0.22,0.48,0.20,0.72,0.01,0.38,0.51,0.00)
CP <- list(x=c(0.72,0.93,0.76,0.61,-0.03,-0.04,0.41),
y=c(0.46,0.76,0.94,1.03,1.01,0.37,0.31))
dxy <- deldir(x,y,rw=c(0,1,0,1))
TL <- tile.list(dxy)
plot(TL,labelPts=TRUE)
plot(TL[16],clipp=CP,fillcol="orange",labelPts=TRUE,add=TRUE)
polygon(CP,border="red")
nbrs <- getNbrs(dxy,interior=CP) # Tiles are clipped to CP.
# Note that point 14 is a neighbour of point 16, even though their
# clipped tiles do not meet.
}
Run the code above in your browser using DataLab