Find the coordinates of a triangle in a mesh

2 ビュー (過去 30 日間)
Florian Spicher
Florian Spicher 2021 年 11 月 3 日
コメント済み: Camille Grimaldi 2023 年 2 月 6 日
I am working with a 2D mesh generated by Gmsh and here I'd like to compute the area of the triangles of in my mesh. What I don't understand is how can I find the coordinates of a given triangle?
In my .m file, I have: msh.nbNod, msh.POS, msh.Max and msh.MIN, msh.LINES, msh.TRIANGLES and msh.PNT.
I think I should somehow use msh.TRIANGLES but I don't get what the numbers listed refer to. If needed, I can post my .m file. Thanks for the help.
  3 件のコメント
Florian Spicher
Florian Spicher 2021 年 11 月 3 日
Done!
Florian Spicher
Florian Spicher 2021 年 11 月 3 日
編集済み: Florian Spicher 2021 年 11 月 3 日
Or maybe I misunderstood what you meant since you edited several times your comment, sorry.

サインインしてコメントする。

採用された回答

Dave B
Dave B 2021 年 11 月 3 日
編集済み: Dave B 2021 年 11 月 3 日
It looks to me like msh.TRIANGLES is referring to indices in msh.POS, which like a reasonable way to describe a mesh.
I'd grab the co-ordinates of a triangle's vertices like this:
squareRing;
triangle_ind=500;
msh.POS(msh.TRIANGLES(triangle_ind,1:3)',:)
ans = 3×3
-1.1902 -0.8650 0 -1.1905 -1.0510 0 -1.3512 -0.9948 0
(Here each row is a vertex, and the columns are x,y,z)
I say it's reasonable, because this is similar to what patch would use (and because max(msh.TRIANGLES(:))==size(msh.POS,1)).
patch('Faces',msh.TRIANGLES(:,1:3),'Vertices',msh.POS,'FaceColor','none','EdgeColor','r')
Note that in the data file you provided, the third column of msh.POS is all zeros, which I assume means that they are all in a 2-D plane.
  5 件のコメント
Florian Spicher
Florian Spicher 2021 年 11 月 4 日
Aha! Now it’s 100% clear! Well, thank you very much :) you really helped
Camille Grimaldi
Camille Grimaldi 2023 年 2 月 6 日
Hi
How did you get the xy for each triangle in the first place?
Cheers
Camille

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by