Reputation: 814
I try to plot a Voronoi diagram of three points:
library(tripack)
x<-c(1.7,-2.2,0.5)
y<-c(-0.6,-0.2,0.8)
v<-voronoi.mosaic(x,y)
plot(v)
However, it just shows an empty plot.
print(v)
gives:
voronoi mosaic:
nodes: (x,y): neighbours (<0: dummy node)
1: (-0.3238956,-1.120482): -1 -2 -3
dummy nodes: (x,y)
1: (-0.3238956,-1.120482)
2: (-0.3238956,-1.120482)
3: (-0.3238956,-1.120482)
Is this a bug? Does this makes sense? In my understanding it should be perfectly fine to build a Voronoi diagram from three points.
Upvotes: 4
Views: 404
Reputation: 162401
Yes, that could be considered a bug, since the definition of Voronoi regions makes good sense for sets with as few as two generator points.
The deldir package (which also implements Delauney triangulation and Dirichlet (Voronoi) tesselation) does correctly handle sets with three (and for that matter as few as two) generator points.
library(deldir)
x <- c(1.7,-2.2,0.5)
y <- c(-0.6,-0.2,0.8)
par(mfcol=c(1,2))
plot(deldir(x, y), asp=1)
plot(deldir(x[1:2], y[1:2]), asp=1)
Upvotes: 5