0001 function xxn = vb_mean_normal_vector_1(Indx,F,V,xx)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 F = F.F3;
0015
0016 Npoint = size(V,1);
0017 Npatch = size(F,1);
0018 xxn = zeros(Npoint,3);
0019 Flg = zeros(Npoint,1);
0020 Flg(Indx) = 1;
0021
0022 xxk = zeros(1,3);
0023 nnk = zeros(1,3);
0024
0025 for i=1:Npatch,
0026
0027 k = F(i,:);
0028
0029 if sum( Flg(k) )==0, continue; end ;
0030
0031
0032 nnk = cross( V(k(2),:)-V(k(1),:) , V(k(3),:)-V(k(1),:) );
0033
0034
0035 nnk = nnk./norm(nnk);
0036
0037
0038
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]);