Calculate the convex hull of a set of points, i.e. the covering polygon that has the smallest area.

## Usage

convex_hull(data)

## Arguments

data

The data points, a numeric matrix with two columns.

## Value

A named list with components:

resverts

The indices of the input vertices that constritute the convex hull.

rescoords

The coordinates of the corners of the convex hull.

## References

Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. Introduction to Algorithms, Second Edition. MIT Press and McGraw-Hill, 2001. ISBN 0262032937. Pages 949-955 of section 33.3: Finding the convex hull.

Other other: running_mean(), sample_seq()

## Author

Tamas Nepusz ntamas@gmail.com

## Examples


M <- cbind(runif(100), runif(100))
convex_hull(M)
#> $resverts #> [1] 2 7 16 41 76 26 74 27 3 47 34 12 #> #>$rescoords
#>               [,1]       [,2]
#>  [1,] 0.6719538004 0.01473970
#>  [2,] 0.1656575357 0.01706923
#>  [3,] 0.0259869604 0.05662120
#>  [4,] 0.0035739134 0.25649774
#>  [5,] 0.0005793779 0.94277215
#>  [6,] 0.4011788100 0.98036703
#>  [7,] 0.5896703757 0.98986755
#>  [8,] 0.9254656709 0.97552540
#>  [9,] 0.9968461362 0.96956068
#> [10,] 0.9982071253 0.96651406
#> [11,] 0.9824077103 0.09188934
#> [12,] 0.9303184026 0.04629297
#>