I need to plot the convex hull given by quickhull algorithm in R. Here is an example.
library(geometry)
x1 <- rnorm(100, 0.8, 0.3)
y1 <- rnorm(100, 0.8, 0.3)
ConVexHull<-convhulln(cbind(x1,y1),"FA")
ConVexHull$hull gives a m-by-dimension index matrix of which each row defines a dim-dimensional “triangle”.
I know how to plot using chull function but I am not sure if chull gives the same hull as given by convhulln
Plot_ConvexHull<-function(xcoord, ycoord, lcolor){
hpts <- chull(x = xcoord, y = ycoord)
hpts <- c(hpts, hpts[1])
lines(xcoord[hpts], ycoord[hpts], col = lcolor)
}
xrange <- range(c(x1))
yrange <- range(c(y1))
par(tck = 0.02, mgp = c(1.7, 0.3, 0))
plot(x1, y1, type = "p", pch = 1, col = "black", xlim = c(xrange), ylim = c(yrange))
Plot_ConvexHull(xcoord = x1, ycoord = y1, lcolor = "black")