VLnearestNeighborN

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Analytical Geometry
Introduced first in SolidGeometry 5.1, Creation date: 2022-01-08, Last change: 2025-09-15

returns the N nearest Neighbors between two point lists

Description

Slower than VLnearestNeighbor beacuse of combinatorial complexity
If you just need triangles, rethink about delaunay triangulation
Much slower than PCfindNearestNeighbors if VL1==VL2

See Also: PCfindNearestNeighbors , VLnearestNeighbor , nearestpair , nearestcluster , PLcorrelate , VLcorrelate

Example Illustration

 missing image of VLnearestNeighborN(VL1,VL2,N,D)

Syntax

[nn,nd]=VLnearestNeighborN(VL1,VL2,[N,D])

Input Parameter

VL1: Point list 1
VL2: Point list 2
N: selection of neighbors; default is [2:3]
D: ''ascend' (default) or 'descend'

Output Parameter

nn: rows of neigbors for VL1 in List VL2
nd: distance to neighbors from VL1 to VL2

Examples


PL=60*rand(10,2); VLnearestNeighborN(PL,PL,2:3); % creates Triangles
PL=60*rand(10,2); VLnearestNeighborN(PL,PL,2:4); % creates Squares
PL=60*rand(10,2); VLnearestNeighborN(PL,PL,1:size(PL,1)) % creates full mesh
PL=PLcircle(50,10); VLnearestNeighborN(PL,PL,[1],'descend') % Spokes
PL=PLcircle(50,10); VLnearestNeighborN(PL,PL,[2 3],'descend') % Spokes
PL=PLcircle(50,10); VLnearestNeighborN(PL,PL,[2 3],'descend'); FL=[[1:size(PL,1)]' ans]




Copyright 2022-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