convex_hull2d() is a S3 generic for computing the convex hull of an
object. It is implemented for Coord2D and Polygon2D objects using
grDevices::chull() and returns a Polygon2D whose vertices are in
counter-clockwise order.
Usage
convex_hull2d(x, ...)
# S3 method for class 'Coord2D'
convex_hull2d(x, ...)
# S3 method for class 'Polygon2D'
convex_hull2d(x, ...)Value
A Polygon2D object representing the convex hull.
Examples
pts <- as_coord2d(x = rnorm(20), y = rnorm(20))
hull <- convex_hull2d(pts)
is_polygon2d(hull)
#> [1] TRUE
hull$is_convex
#> [1] TRUE
plot(hull)
points(pts)
