Close Pairs of Points in 3 Dimensions
Low-level functions to find all close pairs of points in three-dimensional point patterns.
## S3 method for class 'pp3': closepairs(X, rmax, ordered=TRUE, what=c("all", "indices"), ...)
## S3 method for class 'pp3': crosspairs(X, Y, rmax, what=c("all", "indices"), ...)
- Point patterns in three dimensions (objects of class
- Maximum distance between pairs of points to be counted as close pairs.
- Logical value indicating whether all ordered pairs of close points
should be returned. If
ordered=TRUE, each pair will appear twice in the output, as
(i,j)and again as
- String specifying the data to be returned for each close pair of points.
what="all"(the default) then the returned information includes the indices
i,jof each pair, their
x,y,zcoordinates, and the d
These are the efficient low-level functions used by
closepairs(X,rmax) identifies all pairs of neighbours
in the pattern
X and returns them. The result is
a list with the following components:
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
what="indices" then only the components
j are returned. This is slightly faster.
crosspairs(X,rmax) identifies all pairs of neighbours
(X[i], Y[j]) between the patterns
and returns them. The result is
a list with the same format as for
- A list with components
j, and possibly other components as described under Details.
Warning about accuracy
The results of these functions may not agree exactly with
the correct answer (as calculated by a human) and may not
be consistent between different computers and different installations
of R. The discrepancies arise in marginal cases where the interpoint
distance is equal to, or very close to, the threshold
Floating-point numbers in a computer
are not mathematical Real Numbers: they are approximations using
finite-precision binary arithmetic.
The approximation is accurate to a tolerance of about
If the true interpoint distance $d$ and the threshold
are equal, or if their difference is no more than
the result may be incorrect.
X <- pp3(runif(10), runif(10), runif(10), box3(c(0,1))) Y <- pp3(runif(10), runif(10), runif(10), box3(c(0,1))) a <- closepairs(X, 0.1) b <- crosspairs(X, Y, 0.1)