https://github.com/cran/fields
Revision 8182a9a01e5ac26047a101825b76f85617a37cf8 authored by Doug Nychka on 06 February 2009, 21:36:12 UTC, committed by cran-robot on 06 February 2009, 21:36:12 UTC
1 parent e41cdb9
Tip revision: 8182a9a01e5ac26047a101825b76f85617a37cf8 authored by Doug Nychka on 06 February 2009, 21:36:12 UTC
version 5.02
version 5.02
Tip revision: 8182a9a
in.poly.R
# fields, Tools for spatial data
# Copyright 2004-2007, Institute for Mathematics Applied Geosciences
# University Corporation for Atmospheric Research
# Licensed under the GPL -- www.gpl.org/licenses/gpl.html
"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
}
Computing file changes ...