# example delaunayn
d = c(-1,1)
pc = as.matrix(rbind(expand.grid(d,d,d),0))
tc = delaunayn(pc)
# example tetramesh
library(rgl)
rgl.viewpoint(60)
rgl.light(120,60)
tetramesh(tc,pc, alpha=0.9) # render tetrahedron mesh
# example convhulln
# ==> see also surf.tri to avoid unwanted messages printed to the console by qhull
ps = matrix(rnorm(3000),ncol=3) # generate poinst on a sphere
ps = sqrt(3) * ps / drop(sqrt((ps^2) %*% rep(1,3)))
ts.surf = t( convhulln(ps,"QJ") ) # see the qhull documentations for the options
rgl.triangles(ps[ts.surf,1],ps[ts.surf,2],ps[ts.surf,3],col="blue",alpha=.2)
for(i in 1:(8*360)) rgl.viewpoint(i/8)
Run the code above in your browser using DataLab