Home > vbmeg > functions > brain > vb_find_match_point.m

vb_find_match_point

PURPOSE ^

--- Find old vertex point corresponding to new vertex

SYNOPSIS ^

function Indx = vb_find_match_point( Vold, Vnew, Nstep, DispChara)

DESCRIPTION ^

 ---  Find old vertex point corresponding to new vertex
  Indx = vb_find_match_point( Vold, Vnew, Nstep, DispChara)

 Indx      : Old vertex index list corresponding to new vertex

 Vold      : Old vertex point
 Vnew      : New vertex point
 Nstep     : Number of steps to divide Z-axis
 DispChara : Display character

 Originaly written by S.Kajihara
 Ver 1.0  modified by M. Sato  2003-3-15
 Ver 2.0  modified by M. Sato  2005-4-8

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function    Indx = vb_find_match_point( Vold, Vnew, Nstep, DispChara)
0002 % ---  Find old vertex point corresponding to new vertex
0003 %  Indx = vb_find_match_point( Vold, Vnew, Nstep, DispChara)
0004 %
0005 % Indx      : Old vertex index list corresponding to new vertex
0006 %
0007 % Vold      : Old vertex point
0008 % Vnew      : New vertex point
0009 % Nstep     : Number of steps to divide Z-axis
0010 % DispChara : Display character
0011 %
0012 % Originaly written by S.Kajihara
0013 % Ver 1.0  modified by M. Sato  2003-3-15
0014 % Ver 2.0  modified by M. Sato  2005-4-8
0015 %
0016 % Copyright (C) 2011, ATR All Rights Reserved.
0017 % License : New BSD License(see VBMEG_LICENSE.txt)
0018 
0019 if nargin<4, DispChara = []; end;
0020 
0021 % Old model point number
0022 [Npoint, D] = size(Vold);
0023 
0024 % New model point number
0025 Ndipole     = size(Vnew,1);
0026 Indx        = zeros(Ndipole,1);    % Old vertex index list
0027 
0028 % Slice definition
0029 Zmax  = max(Vold(:,3));
0030 Zmin  = min(Vold(:,3));
0031 Zwid  = (Zmax - Zmin)/200;
0032 Zmax  = Zmax + Zwid;
0033 Zmin  = Zmin - Zwid;
0034 Zstep = max( (Zmax-Zmin)/Nstep , eps);
0035 Zlist = Zmin:Zstep:Zmax;
0036 
0037 % Loop for slices in z-direction
0038 for n=1:Nstep,
0039     % Find vertex points in this slice
0040     iold  = find( Vold(:,3) >= Zlist(n) & Vold(:,3) < Zlist(n+1));
0041     inew  = find( Vnew(:,3) >= Zlist(n) & Vnew(:,3) < Zlist(n+1));
0042     Nold  = length(iold);
0043     Nnew  = length(inew);
0044     Vold2 = Vold(iold,:);
0045 
0046     for i=1:Nnew,
0047         k      = inew(i);            % New vertex index
0048         Vnew2 = Vnew( k,:);
0049         
0050         % Distance between new and old vertex
0051         dd    = (Vold2(:,1) - Vnew2(1)).^2 ...
0052             + (Vold2(:,2) - Vnew2(2)).^2 ...
0053             + (Vold2(:,3) - Vnew2(3)).^2;
0054             
0055         % Find nearest old vertex
0056         [md,ix]  = min(dd); 
0057         Indx(k)  = iold(ix);          % Old vertex index for 'k'
0058     end;
0059     
0060     if ~isempty(DispChara), fprintf('%s',DispChara); end;
0061 end
0062 
0063 ixz = find(Indx==0);
0064 if ~isempty(ixz), fprintf('There are unfixed index\n'); end;
0065 %fprintf('--- DEBUG NEW Version\n')

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005