rdelaunayqhull

how to plot non-convex surface from set of n x 3 data


Is there a straight forward way to plot a non-convex surface in R?

I have used something like the following for convex surfaces and it works fine:

xyz <- cbind(y,x,z)
tbr <- t(surf.tri(xyz, delaunayn(xyz)))
rgl.triangles(xyz[tbr,1], xyz[tbr,2], xyz[tbr,3])

However, for non-convex surfaces, concave areas become filled. I think this is a problem with the function delaunayn() as it uses the Qhull library which does not support constrained Delaunay triangulations or mesh generation of non-convex objects.

Any suggestions appreciated.

P.S.

I have data as an ascii file but it has 3 columns and is 225 lines long. What is the best way of providing this?

Data available at: http://pastebin.com/R2p4Cf7d

The top of the plot should be concave! This is an image created using persp3d() of how the surface should look. It has been calculated using more grid points on a regular grid in polar coordinates, rather than using irregular collocation points.

Correct rendering of surface, but with more grid points.


Solution

  • I feel deldir::deldir() does something better than geometry::delaunayn() in this case (as a memorial to a new function rgl::plot3d.deldir()). (I used OP's Data.)

    library(rgl); library(deldir)
    
    dxyz <- deldir(xyz[,1], xyz[,2], z=xyz[,3])
    
    open3d()
    plot3d(dxyz, col=cm.colors(256)[cut(xyz[,3], 256)], alpha=0.9)  # there isn't a bottom
    wire3d(as.mesh3d(dxyz), col="black")
    

    enter image description here