Determines if points are on or in the convex hull of a triangulation object
on.convex.hull.RdGiven a triangulation object tri.obj of \(n\) points in the plane, this
subroutine returns a logical vector indicating if the points
\((x_i,y_i)\)
lay on or in the convex hull of tri.obj.
Usage
on.convex.hull(tri.obj, x, y, eps=1E-16)
in.convex.hull(tri.obj, x, y, eps=1E-16, strict=TRUE)Arguments
- tri.obj
object of class
triSht- x
vector of \(x\)-coordinates of points to locate
- y
vector of \(y\)-coordinates of points to locate
- eps
accuracy for checking the condition
- strict
logical, default
TRUE. It indicates if the convex hull is treated as an open (strict=TRUE) or closed (strict=FALSE) set. (applies only toin.convex.hull)
Author
Albrecht Gebhardt <[email protected]>, Roger Bivand <[email protected]>
Examples
# use a part of the quakes data set:
data(quakes)
quakes.part<-quakes[(quakes[,1]<=-10.78 & quakes[,1]>=-19.4 &
quakes[,2]<=182.29 & quakes[,2]>=165.77),]
q.tri<-tri.mesh(quakes.part$lon, quakes.part$lat, duplicate="remove")
on.convex.hull(q.tri,quakes.part$lon[1:20],quakes.part$lat[1:20])
#> [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE
#> [13] FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE
# Check with part of data set:
# Note that points on the hull (see above) get marked FALSE below:
in.convex.hull(q.tri,quakes.part$lon[1:20],quakes.part$lat[1:20])
#> [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE FALSE
#> [13] TRUE TRUE TRUE TRUE FALSE TRUE TRUE TRUE
# If points both on the hull and in the interior of the hull are meant
# disable strict mode:
in.convex.hull(q.tri,quakes.part$lon[1:20],quakes.part$lat[1:20],strict=FALSE)
#> [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> [16] TRUE TRUE TRUE TRUE TRUE
# something completely outside:
in.convex.hull(q.tri,c(170,180),c(-20,-10))
#> [1] FALSE FALSE