Why are "freeBoundary" surface meshes from tetrahedrons not oriented consistently?
2 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2022 年 5 月 20 日
回答済み: MathWorks Support Team
2022 年 5 月 20 日
Why are "freeBoundary" surface meshes from tetrahedrons not oriented consistently?
採用された回答
MathWorks Support Team
2022 年 5 月 20 日
The triangles returned from the "freeBoundary" function inherit the orientation of the tetrahedrons they originally belonged to.
Orientation of the tetrahedrons is correct when:
(v12 x v13) * v14 > 0
where
vij is the vector between Points i and j : Pj - Pi
i.e. the mathematical volume of the tetrahedron is positive.
Preprocessing the tetrahedrons fixes the inconsistently oriented mesh.
A function to achieve this for an incoming tetrahedron triangulation is:
function [triRet, reversed] = repairTet(tri)
%repair tetrahedron definition
% reverse the tetrahedron connectivity definition when they are
% defined inconsistently
nTetra=size(tri.ConnectivityList,1);
volumes=zeros(nTetra,1); % allocation
for j=1:nTetra
pts=tri.Points(tri.ConnectivityList(j,:),:);
vecs=pts(2:4,:)-pts(1,:);
volumes(j)=1/6*cross(vecs(1,:),vecs(2,:))*(vecs(3,:)');
end
% identify wrongly defined tetrahedrons
reversed=(volumes<0);
temp=tri.ConnectivityList(reversed,:);
tNew=tri.ConnectivityList;
tNew(reversed,:)=temp(:,[1 2 4 3]); % notice the swapping of columns
% create the new tetrahedrons (members of triangulations are read-only)
triRet=triangulation(tNew,tri.Points);
end
The surface mesh returned from the "freeBoundary" function then contains outwards pointing normal vectors.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!