Last chance! 50% off unlimited learning
Sale ends in
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.
inhulln(ch, p)
Convex hull produced using convhulln
An p
represent
A boolean vector with
convhulln
, point.in.polygon
in sp
# NOT RUN {
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)
# }
Run the code above in your browser using DataLab