Learn R Programming

shotGroups (version 0.2-2)

getMaxPairDist: Maximum pairwise distance for a set of points

Description

Calculates the maximum of pairwise distances between points given a set of coordinates.

Usage

getMaxPairDist(xy)

Arguments

xy
a numerical (n x p)-matrix with the coordinates of n points in p-dimensional space (1 row of coordinates per point).

Value

  • A list with the following components
  • dnumerical value with the maximum pairwise distance between points.
  • idxa vector with two entries giving the row indices of the points that are farthest apart.

Examples

Run this code
xy <- matrix(round(rnorm(20, 100, 15), 1), ncol=2)
(maxPD <- getMaxPairDist(xy))

plot(xy, asp=1, pch=16)
segments(x0=xy[maxPD$idx[1], 1], y0=xy[maxPD$idx[1], 2],
         x1=xy[maxPD$idx[2], 1], y1=xy[maxPD$idx[2], 2],
         col="green3", lwd=2)

Run the code above in your browser using DataLab