ComputationalGeometry
ClosestPointPair
determine the closest pair of points in a collection
Calling Sequence
Parameters
Description
Examples
Compatibility
ClosestPointPair(L)
ClosestPointPair(L, cutoff=n)
L
-
list or Array of points with the same dimension
n
positive integer
Find the closest pair of points in L using the classic divide and conquer approach. The answer is returned as an expression sequence with two elements: the distance between a closest pair, and a list with the indices of a pair of points that are closest.
A value n can be given with the cutoff option to customize when the algorithm switches to a brute force search. The default value of 6 has been found to work very well in most cases. A value greater than half the number of points in L will cause the command to work entirely by brute force search.
Setting the infolevel of CompGeomPlot to 4 will cause the command to display a graphical trace of the computation.
with⁡ComputationalGeometry:
ClosestPointPair⁡0,1,2,2,1,1,4,4
1,1,3
L≔seq⁡seq⁡seq⁡i,j,k,i=0..4,0.25,j=0..4,0.25,k=0..4,0.25,1.85,1.85,1.85:
d,p≔ClosestPointPair⁡L
d,p≔0.1732050808,2150,4914
Lp1,Lp2
1.75,1.75,1.75,1.85,1.85,1.85
The ComputationalGeometry[ClosestPointPair] command was introduced in Maple 2019.
For more information on Maple 2019 changes, see Updates in Maple 2019.
See Also
Download Help Document