convex_hull2d: Compute 2D convex hulls

View source: R/coord-methods.r

convex_hull2dR Documentation

Compute 2D convex hulls

Description

convex_hull2d() is a S3 generic for computing the convex hull of an object. There is an implemented method supporting Coord2D class objects using grDevices::chull() to compute the convex hull.

Usage

convex_hull2d(x, ...)

## S3 method for class 'Coord2D'
convex_hull2d(x, ...)

Arguments

x

An object representing object to compute convex hull of such as a Coord2D class object.

...

Further arguments passed to or from other methods.

Value

An object of same class as x representing just the subset of points on the convex hull. The method for Coord2D class objects returns these points in counter-clockwise order.

Examples

p <- as_coord2d(x = rnorm(25), y = rnorm(25))
print(convex_hull2d(p))

# Equivalent to following caculation using `grDevices::chull()`
all.equal(convex_hull2d(p),
          p[rev(grDevices::chull(as.list(p)))])

affiner documentation built on April 4, 2025, 4:42 a.m.