convex_hull: Convex Hull

View source: R/convex_hull.R

convex_hullR Documentation

Convex Hull

Description

Return the convex hull for a set of (x, y) points

Usage

convex_hull(x, y)

Arguments

x

a numeric vector of x coordinates, a n by 2 matrix, or anything that can be coerced to a matrix via as.matrix.

y

a numeric vector of y coordinates, only needed if x is a numeric vector

Details

The convex_hull function returns the vertices, in an anti-clockwise order, of the convex hull encompassing the provided data. This differs from the polygon function as convex hull is generated automatically via Andrew's Monotone algorithm and the polygon function only provides the needed angles between edges of a given set of points.

Value

A sccm_ch object. This is a list with the following elements:

vertices

a n by 2 matrix of the vertices defining the convex hull.

data

a matrix of the data provided

beta

a numeric vector of the exterior angles for each of the vertices.

indices

a numeric vector of the row indices from x corresponding to the data values found to be the vertices of the convex hull.

See Also

polygon p2d d2p p2p

Examples


set.seed(42)
dat <- data.frame(x = rnorm(100), y = rexp(100))
ch <- convex_hull(dat)
ch
plot(ch) 


dewittpe/sccm documentation built on Feb. 2, 2024, 5:25 p.m.