.BG
.VE $Header: /usr3/s/current/s/.help/RCS/chull,v 1.2 83/12/30 19:25:20 rab Exp $
.FN chull
.TL
chull: Convex Hull of a Planar Set of Points
.CS
chull(x, y, peel, maxpeel, onbdy, tol)
.PP
.AG x,y
the co-ordinates of a set of points.  A structure containing
components `x' and `y' may also be given for `x'.
.AG peel
should successive convex hulls be peeled from
the remaining points, generating a nested set of hulls?
Default FALSE.
.AG maxpeel
maximum number of hulls that should be peeled from the data,
default is to peel until all points are assigned to a hull.
If `maxpeel' is given, it implies `peel=TRUE'.
.AG onbdy
should points on the boundary of a convex hull (but
not vertices of the hull) be included in the hull?  Default
FALSE, unless `peel' is TRUE in which case `onbdy' is TRUE by default.
.AG tol
relative tolerance for determining inclusion on hull, default .0001.
.RT
vector giving the indices of the points on the hull.  If
`peel' is TRUE, returns a data structure with components
`depth', `hull' and `count'.
.RC depth
a vector which assigns a depth to each point, i.e., the
number of hulls surrounding the point.  Outliers will have
small values of `depth', interior points relatively large
values.
.RC hull
vector giving indices of the points on the hull.  Along with
`count', determines all of the hull peels.  The first
`count[1]' values of `hull' determine the outermost hull,
the next  `count[2]' are the second hull, etc.
.RC count
counts of the number of points on successive hulls.
.EX
hull <- chull(x,y)
plot(x,y)
hatch(x[hull],y[hull],space=0)  # draw hull

p <- chull(x,y,peel=T)   # all hulls
which <- rep(seq(p$count),p$count)   # which peel for each pt
s <- split(p$hull,which)
for(i in seq(ncomp(s))){     # plot all peels
      j <- s$[i]    # indices of points on ith peel
      hatch(x[j],y[j],space=0,lty=i)
      }
.KW plot*
.KW dplot*
.WR
