An object of class "metric"
defines a measure of distance
between points, and supports many operations that involve distances.
Adrian Baddeley Adrian.Baddeley@curtin.edu.au, Rolf Turner rolfturner@posteo.net and Ege Rubak rubak@math.aau.dk.
A ‘metric’ \(d\) is a measure of distance between points that satisfies
\(d(x,x) = 0\) for any point \(x\),
\(d(x,y) > 0\) for any two distinct points \(x\) and \(y\)
symmetry: \(d(x,y) = d(y,x)\) for any two points \(x\) and \(y\)
triangle inequality: \(d(x,y) \le d(x,z) + d(z,y)\) for any three points \(x,y,z\).
The Euclidean distance between points is an example of a metric.
An object of class "metric"
is a structure
that defines a metric and supports many computations that involve
the metric. The internal structure of this object,
and the mechanism for performing these computations,
are under development.
Objects of class "metric"
are produced by the function
convexmetric
and possibly by other functions.
There are methods for print
and summary
for the class "metric"
.
The summary
method lists the operations that are supported
by the metric.
To perform distance calculations (for example, nearest-neighbour
distances) using a desired metric instead of the
Euclidean metric, first check whether the standard function for this
purpose (for example nndist.ppp
)
has an argument named metric
.
If so, use the standard function
and add the argument metric
; if not, use
the low-level function invoke.metric
.
convexmetric
, invoke.metric
m <- convexmetric(square(c(-1,1)))
summary(m)
y <- nndist(cells, metric=m)
Run the code above in your browser using DataLab