https://github.com/cran/fields
Tip revision: 6769ffc81115fbf0bf7d9c566cf7ac81be0049dc authored by Doug Nychka on 25 July 2005, 00:00:00 UTC
version 3.04
version 3.04
Tip revision: 6769ffc
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
}