convexHullAM: Convex Hull via Andrews Monotone, Rcpp Interface to C++...

Description Usage Arguments Value Examples

Description

This function is the R interface to the C++ implementation of Andrews Monotone, a well known algorithm for solving the convex hull in O(nlogn) time complexity.

Usage

1
2
convexHullAM_Indexes(x, y, includeColinear=FALSE,zeroBased = TRUE)
convexHullAM_Points(x, y,includeColinear=FALSE)

Arguments

x

NumericVector of x values

y

NumericVector of y values

includeColinear

whether to inlude points that line ON the hull, by default this is set to FALSE, as this is the true definition of the convex hull.

zeroBased

Whether the return indexes should be zero based (true, for use in C++), or One-Based (false, for use in R).

Value

convexHullAM_Indexes returns an integer vector of the indexes of the points, whilst convexHullAM_Points returns an n x 2 matrix of the points themselves.

Examples

1
2
3
4
5
6
7
8
9
library(contoureR)
library(ggplot2)
set.seed(1)
x  = runif(100)
y  = runif(100)
ch = convexHullAM_Indexes(x,y,includeColinear=FALSE,zeroBased = FALSE)
ggplot(data.frame(x,y),aes(x,y)) +
 geom_point() +
 geom_path(data=data.frame(x,y)[ch,],colour="red")

contoureR documentation built on May 2, 2019, 12:08 p.m.