Find nearest 3D & 2D-coordinate to the target point Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [Vp, Xp, Yp, dmin] = vb_get_3d_point(xp,V,X,Y) 0002 % Find nearest 3D & 2D-coordinate to the target point 0003 % 0004 % Copyright (C) 2011, ATR All Rights Reserved. 0005 % License : New BSD License(see VBMEG_LICENSE.txt) 0006 0007 NP = size(xp,1); 0008 Id = zeros(NP,1); 0009 dmin = zeros(NP,1); 0010 0011 % Find 2D-point index near the target point 0012 for n = 1:NP 0013 dd = (X - xp(n,1)).^2 + (Y - xp(n,2)).^2; 0014 [ddmin, ix] = min(dd); 0015 Id(n) = ix; 0016 dmin(n) = sqrt(ddmin); 0017 end; 0018 0019 Vp = V(Id,:); 0020 Xp = X(Id,:); 0021 Yp = Y(Id,:);