https://github.com/cran/fields
Tip revision: 92636eaee56714c89c7b7e7cdc52e0c77aeb79b3 authored by Doug Nychka on 07 February 2005, 00:00:00 UTC
version 2.3
version 2.3
Tip revision: 92636ea
in.poly.r
"in.poly" <-
function (xd, xp, convex.hull = FALSE, inflation=1e-7)
{
if (convex.hull) {
xp <- xp[chull(xp), ]
}
nd <- nrow(xd)
np <- as.integer(nrow(xp))
#
# inflate convex hull slightly to include any points actually on the hull
#
if( convex.hull){
xm<- matrix(c(mean(xp[,1]), mean( xp[,2])), nrow=np, ncol=2,byrow=TRUE)
xp<- (xp- xm)*( 1+ inflation) + xm
}
.Fortran("inpoly", nd = as.integer(nd), as.single(xd[, 1]),
as.single(xd[, 2]), np = np, as.single(xp[, 1]), as.single(xp[,
2]), ind = as.integer(rep(-1, nd)), PACKAGE="fields")$ind
}