nearestpair

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Analytical Geometry
Introduced first in SolidGeometry 3.9, Creation date: 2017-06-04, Last change: 2025-09-14

returns the nearest point pairs of two vector list

Description

Two vector list are processed using the norm distance. If the parameter 'unique' is used, then e vector that was used already cannot be used a second time. The index zero shows that there is no corresponding vector in the second list
For the points that could win the nearast pair race get the nearest point as partner in a second list


See Also: , nearestcluster , connectofmat , PLcorrelate , CPLcorrelate , VLnearestNeighbor

Example Illustration

 missing image of nearestpair(PLA,PLB,tp);

Syntax

[p,x,D,pn]=nearestpair(PLA,PLB,[tp]);

Input Parameter

PLA: Vector list A
PLB: Vector list B
tp: 'min', 'mean' ; default is 'min'

Output Parameter

p: [Ai Bi] index list for the exclusive pairs
x: Distance between the pairs
D: Full Distance matrix
pn: [Ai Bi] index list for the unpaired points

Examples


D1=rand(10,2); D2=rand(10,2);
nearestpair(D1,D2,'mean');
nearestpair(D1,D2,'min');
D1=rand(10,2); D2=rand(5,2);
nearestpair(D1,D2,'min')
nearestpair(D2,D1,'min')




Copyright 2017-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Last html export of this page out of FM database by TL: 2025-09-21