Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

inhulln

Test if points lie in convex hull


Description

Tests if a set of points lies within a convex hull, returning a boolean vector in which each element is TRUE if the corresponding point lies within the hull and FALSE if it lies outwith the hull or on one of its facets.

Usage

inhulln(ch, p)

Arguments

ch

Convex hull produced using convhulln

p

An M-by-N matrix of points to test. The rows of p represent M points in N-dimensional space.

Value

A boolean vector with M elements

Note

inhulln was introduced in geometry 0.4.0, and is still under development. It is worth checking results for unexpected behaviour.

Author(s)

David Sterratt

See Also

convhulln, point.in.polygon in sp

Examples

p <- cbind(c(-1, -1, 1), c(-1, 1, -1))
ch <- convhulln(p)
## First point should be in the hull; last two outside
inhulln(ch, rbind(c(-0.5, -0.5),
                  c( 1  ,  1),
                  c(10  ,  0)))

## Test hypercube
p <- rbox(D=4, B=1)
ch <- convhulln(p)
tp <-  cbind(seq(-1.9, 1.9, by=0.2), 0, 0, 0)
pin <- inhulln(ch, tp)
## Points on x-axis should be in box only betw,een -1 and 1
pin == (tp[,1] < 1 & tp[,1] > -1)

geometry

Mesh Generation and Surface Tessellation

v0.4.5
GPL (>= 3)
Authors
Jean-Romain Roussel [cph, ctb] (wrote tsearch function with QuadTrees), C. B. Barber [cph], Kai Habel [cph, aut], Raoul Grasman [cph, aut], Robert B. Gramacy [cph, aut], Pavlo Mozharovskyi [cph, aut], David C. Sterratt [cph, aut, cre] (<https://orcid.org/0000-0001-9092-9099>)
Initial release
2019-12-02

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.