KNNSearch.m 1.41 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
% KNNSearch query a GL-tree for k nearest neighbor(kNN)
%
% SYNTAX
%
% [kNNG]=KNNSearch(p,qp,ptrtree,k);       short
% [kNNG,Dist]=KNNSearch(p,qp,ptrtree,k);  long
%
% INPUT PARAMETERS
% 
%       p: [Nx3] double array coordinates of reference points
% 
%       qp: [Nqx3] double array coordinates of query points
%
%       ptrtree: a pointer to the previously constructed  GLtree.Warning
%                if the pointer is uncorrect it will cause a crash, there is
%                no way to check this in the mex routine, you have to check
%                yourself in your script.
%
%       k: number of neighbors
%
% OUTPUT PARAMETERS
%
%      kNNG: [Nqxk] array, each rows contains the kNN indexes
%            So in row one there are kNN to first query
%           point, in row two to the second etc...
% 
%      Dist: [Nqxk] array, Facultative output, each rows contains the
%                   distance values of the  found kNN.
%         
%
%
%
% GENERAL INFORMATIONS
%
%         -This function is faster if all query points are given once
%         instead of looping and pass one point each loop.
%
%
%  For question, suggestion, bug reports
%  giaccariluigi@msn.com
% 
% Visit my website:
% http://giaccariluigi.altervista.org/blog/
%
% This work is free thanks to users gratitude, if you find it usefull
% please consider making a donation on my website.
%
%  Author : Luigi Giaccari
%  Last Update: 2/1/2009
%  Created : 8/8/2008