Learn R Programming

affiner (version 0.1.3)

convex_hull2d: 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 Coord2D convex_hull2d(x, ...)

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.

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.

Examples

Run this code
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)))])

Run the code above in your browser using DataLab