convhulln {geometry}R Documentation

Compute smallest convex hull that encloses a set of points

Description

Returns an index matrix to the points of simplices (“triangles”) that form the smallest convex simplicial complex of a set of input points in N-dimensional space.

Usage

convhulln(p, options = " ")

Arguments

p An n-by-dim matrix. The rows of p represent n points in dim-dimensional space.
options Optional options, see details below.

Details

This function interfaces the qhull library, and intends to be a port from Octave to R.

The input n-by-dim matrix contains n points of dimension dim. If a second optional argument is given, it must be a string containing extra options for the underlying qhull command. (See the Qhull documentation for the available options - refer to delaunayn.)

Value

An m-by-dim index matrix of which each row defines a dim-dimensional “triangle”. The indices refer to the rows in p.

Note

This intents to be a port of the Octave's (http://www.octave.org) geometry library. The sources originals were from Kai Habel.

All console printing is sent to a file in the CWD called “qhull_out.txt” unless another file is specified with the TO option – see the qhull documentation. To get the usual progress-related output specify the R-specific option "Pp Ps".

See further notes in delaunayn.

Author(s)

Raoul Grasman and Robert B. Gramacy bobby@statslab.cam.ac.uk

References

Barber, C.B., Dobkin, D.P., and Huhdanpaa, H.T., “The Quickhull algorithm for convex hulls,” ACM Trans. on Mathematical Software, Dec 1996.

http://www.qhull.org

See Also

convex.hull, delaunayn, surf.tri, distmesh2d

Examples

# example delaunayn
d = c(-1,1)
pc = as.matrix(rbind(expand.grid(d,d,d),0))
tc = delaunayn(pc)

# example tetramesh
## Not run: 
library(rgl)
rgl.viewpoint(60)
rgl.light(120,60)
tetramesh(tc,pc, alpha=0.9)    # render tetrahedron mesh
## End(Not run)

# 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
## Not run: 
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)
## End(Not run)

[Package geometry version 0.1-1 Index]