\HeaderA{chull}{Compute Convex Hull of a Set of Points}{chull}
\keyword{graphs}{chull}
\begin{Description}\relax
Computes the subset of points which lie on the convex hull of the
set of points specified.
\end{Description}
\begin{Usage}
\begin{verbatim}
chull(x, y = NULL)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x, y}] coordinate vectors of points. This can be specified as two
vectors \code{x} and \code{y}, a 2-column matrix \code{x}, a list
\code{x} with two components, etc, see \code{\LinkA{xy.coords}{xy.coords}}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{\LinkA{xy.coords}{xy.coords}} is used to interpret the
specification of the points. The algorithm is that given by Eddy (1977).

\sQuote{Peeling} as used in the S function \code{chull} can be
implemented by calling \code{chull} recursively.
\end{Details}
\begin{Value}
An integer vector giving the indices of the points lying on the
convex hull, in clockwise order.
\end{Value}
\begin{References}\relax
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
\emph{The New S Language}.
Wadsworth \& Brooks/Cole.

Eddy, W. F. (1977) A new convex hull algorithm for planar sets.
\emph{ACM Transactions on Mathematical Software}, \bold{3}, 398--403.

Eddy, W. F. (1977) Algorithm 523. CONVEX, A new convex hull
algorithm for planar sets[Z]. \emph{ACM Transactions on
Mathematical Software}, \bold{3}, 411--412.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{xy.coords}{xy.coords}},\code{\LinkA{polygon}{polygon}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
require(stats)
X <- matrix(rnorm(2000), ncol = 2)
chull(X)
## Not run: 
  # Example usage from graphics package
  plot(X, cex = 0.5)
  hpts <- chull(X)
  hpts <- c(hpts, hpts[1])
  lines(X[hpts, ])
## End(Not run)
\end{ExampleCode}
\end{Examples}

