Home > functions > brain > vb_mean_normal_vector_2.m

vb_mean_normal_vector_2

PURPOSE ^

xxn : 平均法線方向 = 自分の周りの面の法線方向の平均( 面積で重み付け )

SYNOPSIS ^

function xxn = vb_mean_normal_vector_2(Indx,F,V,xx)

DESCRIPTION ^

    xxn     : 平均法線方向 = 自分の周りの面の法線方向の平均( 面積で重み付け )

   Indx     : 法線方向を計算するダイポールの頂点番号
  V(n, 1:3) : ダイポールの位置
 xx(n, 1:3) : ダイポールの方向(nx,ny,nz)

 Originaly written by S.Kajihara
 Ver 1.0  modified by M. Sato  2003-3-15

 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    xxn = vb_mean_normal_vector_2(Indx,F,V,xx)
0002 %    xxn     : 平均法線方向 = 自分の周りの面の法線方向の平均( 面積で重み付け )
0003 %
0004 %   Indx     : 法線方向を計算するダイポールの頂点番号
0005 %  V(n, 1:3) : ダイポールの位置
0006 % xx(n, 1:3) : ダイポールの方向(nx,ny,nz)
0007 %
0008 % Originaly written by S.Kajihara
0009 % Ver 1.0  modified by M. Sato  2003-3-15
0010 %
0011 % Copyright (C) 2011, ATR All Rights Reserved.
0012 % License : New BSD License(see VBMEG_LICENSE.txt)
0013 
0014 F          = F.F3;
0015 
0016 Npoint      = size(V,1);          % number of dipoles
0017 Npatch      = size(F,1);          % number of patch
0018 xxn       = zeros(Npoint,3);    % Mean normal vector
0019 Flg       = zeros(Npoint,1);    
0020 Flg(Indx) = 1;                    % Flag for dipole index
0021 
0022 xxk       = zeros(1,3);
0023 nnk       = zeros(1,3);
0024 
0025 for i=1:Npatch,
0026     % 3角面の頂点インデックス
0027     k      = F(i,:); 
0028     
0029     if sum( Flg(k) )==0,  continue; end ;
0030     
0031     % 3角面の法線ベクトル
0032     nnk   = cross( V(k(2),:)-V(k(1),:) , V(k(3),:)-V(k(1),:) );
0033 
0034     % Normalization
0035 %    nnk   = nnk./norm(nnk);
0036     
0037     % 3角面の法線ベクトル 'nnk' と向きが同じ
0038     % 頂点の法線ベクトル 'xx' の数を数える
0039     xdot  = sum( xx(k,:) .* repmat(nnk ,[3,1]) ,2);
0040     xsign = sum(sign(xdot));
0041     nnk   = sign(xsign)*nnk;
0042 
0043     % 法線の平均
0044     xxn(k,:) = xxn(k,:) + repmat(nnk ,[3,1]);
0045 end
0046 
0047 xxn  = xxn(Indx,:);
0048 xxn2 = sqrt(sum(xxn.^2 , 2));
0049 xxn  = xxn./repmat(xxn2, [1 3]);

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005