chull
Convex Hull of a Planar Set of Points
Description
Returns a vector that describes the convex hull(s) of a set of points.
Any number of nested convex hulls can be generated, including the entire set.
Usage
chull(x, y=NULL, peel = FALSE, maxpeel = length(x), onbdy = peel, tol = 1e-12)
Arguments
x,y |
the coordinates of points.
The coordinates can be given by two vector arguments
or by a single argument, x, which is a times series,
a two-column matrix,
or a list containing components named x and y.
See xy.coords.
Missing values are not accepted.
|
peel |
a logical value. If TRUE, successive convex hulls are peeled from
the remaining points, generating a nested set of hulls. The default is FALSE.
This argument is not available in the open-source R chull function.
|
maxpeel |
the maximum number of hulls to peel from the data.
The default, if peel is TRUE,
is to peel until all points are assigned to a hull.
If maxpeel is given, peel is set to TRUE.
This argument is not available in the open-source R chull function.
|
onbdy |
a logical value. If TRUE, points on the boundary of a convex hull
(but not vertices of the hull)
are included in the hull.
This argument is not available in the open-source R chull function.
|
tol |
a numeric relative tolerance for determining
if a third point is sufficiently collinear to two points in the hull
to also include in the hull.
This argument is not available in the open-source R chull function.
|
Details
This function finds the convex hull of a set of points in the plane.
It is based on a C translation (by f2c) of ACM Transactions on
Mathematical Software (TOMS) algorithm 523
by W. F. Eddy, vol 3 (1977), 398-403, 411-2.
Value
- If peel is FALSE, returns
a vector containing the indices of the points on the hull.
- If peel is TRUE, returns a list with the following components.
depth |
a vector that assigns a depth to each point;
that is, the number of hulls surrounding the point
(the outermost points are at depth 1).
Outliers have small values of depth;
interior points have relatively large values. |
hull |
the vector containing the indices of the points on the hull.
Along with count, hull determines all of the hull peels.
count[1] values of hull determines the outermost hull,
count[2] values of hull determines the second hull, and so on. |
count |
the counts of the number of points on successive hulls.
|
Differences between Spotfire Enterprise Runtime for R and Open-source R
The arguments: peel, maxpeel, onbdy and tol
are not available in Open-source R's chull function.
References
Barnett, V. 1976. The ordering of multivariate data. Journal of the Royal Statistical Society, Series A . Volume 139, 318-354.
Eddy, W. F. 1977. Algorithm 523: CONVEX, A New Convex Hull Algorithm for Planar Sets. Journal of ACM Transactions on Mathematical Software (TOMS) Volume 3, 398-403, 411-412.
See Also
Examples
x <- 1:12
y <- c(0.5, 0.2, -0.3, 3.2, 0, 1, 9, -3, 3, 4, 7, 8)
hull <- chull(x,y) # hull is: 8 1 7 12
X <- matrix(rnorm(2000), ncol = 2)
hpts <- chull(X)