Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

pairdist.pp3

Pairwise distances in Three Dimensions


Description

Computes the matrix of distances between all pairs of points in a three-dimensional point pattern.

Usage

## S3 method for class 'pp3'
pairdist(X, ..., periodic=FALSE, squared=FALSE)

Arguments

X

A point pattern (object of class "pp3").

...

Ignored.

periodic

Logical. Specifies whether to apply a periodic edge correction.

squared

Logical. If squared=TRUE, the squared distances are returned instead (this computation is faster).

Details

This is a method for the generic function pairdist.

Given a three-dimensional point pattern X (an object of class "pp3"), this function computes the Euclidean distances between all pairs of points in X, and returns the matrix of distances.

Alternatively if periodic=TRUE and the window containing X is a box, then the distances will be computed in the ‘periodic’ sense (also known as ‘torus’ distance): opposite faces of the box are regarded as equivalent. This is meaningless if the window is not a box.

If squared=TRUE then the squared Euclidean distances d^2 are returned, instead of the Euclidean distances d. The squared distances are faster to calculate, and are sufficient for many purposes (such as finding the nearest neighbour of a point).

Value

A square matrix whose [i,j] entry is the distance between the points numbered i and j.

Author(s)

based on two-dimensional code by Pavel Grabarnik.

See Also

Examples

if(require(spatstat.core)) {
   X <- runifpoint3(20)
} else {
   X <- osteo$pts[[1]]
}
   d <- pairdist(X)
   d <- pairdist(X, periodic=TRUE)
   d <- pairdist(X, squared=TRUE)

spatstat.geom

Geometrical Functionality of the 'spatstat' Family

v2.1-0
GPL (>= 2)
Authors
Adrian Baddeley [aut, cre], Rolf Turner [aut], Ege Rubak [aut], Tilman Davies [ctb], Ute Hahn [ctb], Abdollah Jalilian [ctb], Sebastian Meyer [ctb], Suman Rakshit [ctb], Dominic Schuhmacher [ctb], Rasmus Waagepetersen [ctb]
Initial release
2021-04-15

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.