Home > vbmeg > functions > tool_box > dynamics_movie > test_fig > basic_tool > get_shortest_path.m

get_shortest_path

PURPOSE ^

get_shortest_path along head

SYNOPSIS ^

function [Xpath, Npath] = get_shortest_path(parm, facefile)

DESCRIPTION ^

 get_shortest_path along head

 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    [Xpath, Npath] = get_shortest_path(parm, facefile)
0002 % get_shortest_path along head
0003 %
0004 % Copyright (C) 2011, ATR All Rights Reserved.
0005 % License : New BSD License(see VBMEG_LICENSE.txt)
0006 
0007 % Face surface
0008 face = load(facefile);
0009 V = face.Vspm;
0010 F = face.F;
0011 xx = face.xx;
0012 
0013 % Pair channel
0014 ix_from = parm.probe_pair(:, 1);
0015 ix_to   = parm.probe_pair(:, 2);
0016 
0017 src_pos = parm.src_pos(ix_from, :);
0018 det_pos = parm.det_pos(ix_to, :);
0019 
0020 % Map start(X1) & end(X2) points on surface
0021 [Indx ,derr] = vb_find_nearest_point(V,src_pos);
0022 X1 = V(Indx,:);
0023 xx1 = xx(Indx,:);
0024 
0025 [Indx ,derr] = vb_find_nearest_point(V,det_pos);
0026 X2 = V(Indx,:);
0027 xx2 = xx(Indx,:);
0028 
0029 % Maximum edge length of surface patch
0030 xxD = vb_next_distance(F,V);
0031 % xxD{n} : 頂点 n と 各隣接近傍点 との 距離
0032 dmax = max(vb_cell_merge(xxD));
0033 
0034 %
0035 % ----- shortest path from source to detector
0036 %
0037 Npair = size(src_pos,1);
0038 Xpath = cell(Npair,1);
0039 Npath = zeros(Npair,1);
0040 
0041 for k=1:Npair
0042     V1 = X1(k,:); % source
0043     V2 = X2(k,:); % detector
0044     xn = (xx1(k,:) + xx2(k,:))/2; % mean normal direction
0045     
0046     % Find the shortest path from V1 to V2 along surface
0047     % The plane is defined by (V2 - V1) & the normal direction 'xn'
0048     % The path is cross section of surface and plane
0049     Vpath = plane_cross_section(V,F,V1,V2,xn,dmax);
0050     Xpath{k} = Vpath;
0051     Npath(k) = size(Vpath,1);
0052 end
0053

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