[indices, bestSqDist] = nearpoints(src, dest) For each point in one set, find the nearest point in another. - src is a 3xM array of points - dest is a 3xN array of points - indices is a 1xM vector, in which each element tells which point in dest is closest to the corresponding point in src. For example, dest[indices[i]] is near src[i]. - bestSqDist is a 1xM array of the squared distance between dest[indices[i]] and src[i]. Compile the mex function with something like: mex -O nearpoints.cxx HISTORY: 2004.05.01 Dan Merget wrote it.
0001 function nearpoints 0002 % 0003 % [indices, bestSqDist] = nearpoints(src, dest) 0004 % 0005 % For each point in one set, find the nearest point in another. 0006 % 0007 %- src is a 3xM array of points 0008 %- dest is a 3xN array of points 0009 %- indices is a 1xM vector, in which each element tells which point 0010 % in dest is closest to the corresponding point in src. For 0011 % example, dest[indices[i]] is near src[i]. 0012 %- bestSqDist is a 1xM array of the squared distance between 0013 % dest[indices[i]] and src[i]. 0014 % 0015 % Compile the mex function with something like: 0016 % mex -O nearpoints.cxx 0017 % 0018 % HISTORY: 0019 % 2004.05.01 Dan Merget wrote it. 0020 0021 disp('To compile, try:'); 0022 disp(['cd ' fileparts(which(mfilename)) '; mex -O ' mfilename '.c']); 0023 error('This function must be compiled!');