# 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)
# example surf.tri
# ==> see also convhulln, but it currently prints an unavoidable
# message to the console
ps = matrix(rnorm(3000),ncol=3) # generate poinst on a sphere
ps = sqrt(3) * ps / drop(sqrt((ps^2) %*%rep(1,3)))
ts = delaunayn(ps)
ts.surf = t( surf.tri(ps,ts) )
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