Home > vbmeg > functions > leadfield > sphere > vb_make_triangle.m

vb_make_triangle

PURPOSE ^

SYNOPSIS ^

function F = vb_make_triangle(Jlist)

DESCRIPTION ^

 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    F = vb_make_triangle(Jlist)
0002 %
0003 % Copyright (C) 2011, ATR All Rights Reserved.
0004 % License : New BSD License(see VBMEG_LICENSE.txt)
0005 
0006 % Jlist{n} : theta(n) に対応する点のインデックス
0007 
0008 Ntheta = size(Jlist,1);
0009 F = [];
0010 
0011 for n=1:(Ntheta-1),
0012     jx1 = Jlist{n};
0013     jx2 = Jlist{n+1};
0014     N1    = length(jx1);
0015     N2    = length(jx2);
0016     ND    = N2-N1;
0017 
0018     if ND<0,
0019         % Swap jx1 and jx2
0020         jxx = jx1;
0021         NN    = N1;
0022         jx1 = jx2;
0023         jx2 = jxx;
0024         N1    = N2;
0025         N2    = NN;
0026         ND    = -ND;
0027     end;
0028     
0029     % Add (2*pi)-index
0030     jx1=[jx1 jx1(1)];
0031     jx2=[jx2 jx2(1)];
0032     
0033     if N1==1,
0034         % North or South pole
0035         ii = ones(1,N2);
0036         jj = 1:N2;
0037         F1 = [ jx1(ii); jx2(jj); jx2(jj+1)];
0038         F  = [ F, F1];
0039     elseif ND==0,
0040         % N1 = N2 case
0041         ii = 1:N1;
0042         F1 = [ jx1(ii); jx2(ii)  ; jx2(ii+1)];
0043         F2 = [ jx1(ii); jx1(ii+1); jx2(ii+1)];
0044         F  = [F , F1, F2 ];
0045     else
0046         % 交互にfix(N1/ND)とceil(N1/ND)の間隔で
0047         % 余分な三角形を配置する
0048         NS = [fix(N1/ND) , ceil(N1/ND)];
0049         nf = -1;
0050 
0051         N1 = N1+1; 
0052         N2 = N2+1;
0053         i  = 1; 
0054         j  = 1; 
0055         n  = 0 ;
0056         
0057         
0058         while i < N1,
0059             
0060             if n < ND,
0061                 % 交互にfix(N1/ND)とceil(N1/ND)の間隔を使用
0062                 NL = NS( (nf+1)/2 + 1 );
0063                 nf = -nf;
0064                 
0065                 iz=(i+NL-1);
0066                 if iz >= N1, 
0067                     iz = N1-1; 
0068                     NL = N1-i; 
0069                 end;
0070 
0071                 jz=(j+NL-1);
0072                 if jz >= N2, 
0073                     jz = N2-1; 
0074                     NL = N2-j; 
0075                     iz = i+NL-1;
0076                 end;
0077                 
0078                 ii = i:iz;
0079                 jj = j:jz;
0080 
0081                 F1 = [ jx1(ii); jx2(jj)  ; jx2(jj+1)];
0082                 F2 = [ jx1(ii); jx1(ii+1); jx2(jj+1)];
0083                 F  = [F , F1, F2 ];
0084 
0085                 i  = i+NL;
0086                 j  = j+NL+1;
0087                 n  = n+1;
0088                 
0089                 F3 = [ jx1(i); jx2(j-1); jx2(j)];
0090                 F  = [F, F3];
0091             else
0092                 ii=i:(N1-1);
0093                 jj=j:(N2-1);
0094                 
0095                 F1 = [ jx1(ii); jx2(jj)  ; jx2(jj+1)];
0096                 F2 = [ jx1(ii); jx1(ii+1); jx2(jj+1)];
0097                 F  = [F , F1, F2 ];
0098                 
0099                 i  = N1;
0100                 j  = N2;
0101             % if-ND-end
0102             end;
0103         % while-end
0104         end;
0105     % if-else-end
0106     end;
0107 % theta-loop
0108 end;
0109 
0110 F = F';

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