# include "sp.h" # include #define ROFFSET 1 int pipbb(double pt1, double pt2, double *bbs); int between(double x, double low, double up); SEXP pointsInBox(const SEXP lb, const SEXP px, const SEXP py); SEXP tList(const SEXP nl, const SEXP m); SEXP tList(const SEXP nl, const SEXP m0) { int n=Rf_length(nl), m=INTEGER_POINTER(m0)[0], i, ii, j, jj, *k, pc=0; SEXP res; PROTECT(res = NEW_LIST(m)); pc++; k = (int *) R_alloc((size_t) m, sizeof(int)); for (j=0; j 0) { for (j=0; j= m) Rf_error("invalid indices"); k[jj]++; } } } for (j=0; j 0) { for (j=0; j= low && x <= up) return(1); else return(0); } int pipbb(double pt1, double pt2, double *bbs) { if ((between(pt1, bbs[0], bbs[2]) == 1) && (between(pt2, bbs[1], bbs[3]) == 1)) return(1); else return(0); }