https://github.com/cran/fields
Tip revision: ce722edae3c1b9e1af2985ce3500b11058facf0e authored by Doug Nychka on 24 August 2006, 01:46:17 UTC
version 3.04
version 3.04
Tip revision: ce722ed
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
}