Voronoi diagram graph with three points using R and tripack packet

I am trying to build 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)

This is mistake? It makes sense? In my opinion, it would be nice to build a Voronoi diagram from three points.

+4
source share
1 answer

Yes, this can be considered a mistake, since the definition of Voronoi regions makes sense for sets with an integer of two generator points,

The deldir package (which also implements Delauney and Tesselation Dirichlet (Voronoi) triangulation) correctly processes sets with three (and in this case only 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)

enter image description here

+5
source

Source: https://habr.com/ru/post/1614642/


All Articles