Home > functions > common > boundary > vb_triangle_normal.m

vb_triangle_normal

PURPOSE ^

normal vector of patch triangle

SYNOPSIS ^

function xxf = vb_triangle_normal(V,F)

DESCRIPTION ^

 normal vector of patch triangle
  xxf = vb_triangle_normal(V,F)

 --- Input
 V : vertex of surface
 F : triangle patch index
 --- Output
 xxf  : normal vector of triangle

 Ver 1.0  by M. Sato  2004-2-10

 三角面の法線と頂点法線計算
  V(n, 1:3)  : 頂点の位置
  F(j, 1:3)  : 三角面3頂点のインデックス

 xxf : 3角面の法線ベクトル
 xxn : 頂点法線 = 頂点に隣接する三角面法線の平均

 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    xxf = vb_triangle_normal(V,F)
0002 % normal vector of patch triangle
0003 %  xxf = vb_triangle_normal(V,F)
0004 %
0005 % --- Input
0006 % V : vertex of surface
0007 % F : triangle patch index
0008 % --- Output
0009 % xxf  : normal vector of triangle
0010 %
0011 % Ver 1.0  by M. Sato  2004-2-10
0012 %
0013 % 三角面の法線と頂点法線計算
0014 %  V(n, 1:3)  : 頂点の位置
0015 %  F(j, 1:3)  : 三角面3頂点のインデックス
0016 %
0017 % xxf : 3角面の法線ベクトル
0018 % xxn : 頂点法線 = 頂点に隣接する三角面法線の平均
0019 %
0020 % Copyright (C) 2011, ATR All Rights Reserved.
0021 % License : New BSD License(see VBMEG_LICENSE.txt)
0022 
0023 Npoint = size(V,1);      % 頂点数
0024 Npatch = size(F,1);
0025 
0026 % 三角面3頂点のインデックス
0027 F1     = F(:,1);
0028 F2     = F(:,2);
0029 F3     = F(:,3);
0030 
0031 % 三角面3頂点
0032 V1 = V(F1,:);
0033 V2 = V(F2,:);
0034 V3 = V(F3,:);
0035 
0036 % 3角面の法線ベクトル
0037 xxf = vb_cross2( V2 - V1, V3 - V1 );
0038 
0039 % Normalization
0040 xxs = sqrt(sum(xxf.^2,2));
0041 xxs = max(xxs,eps);
0042 xxf = xxf./xxs(:,ones(1,3));
0043

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