How to calculate the volume of a 3D triangular mesh?

11 ビュー (過去 30 日間)
Hadi Ghahremannezhad
Hadi Ghahremannezhad 2019 年 11 月 21 日
編集済み: Ridwan Alam 2019 年 11 月 21 日
I have a pyramid with these vertices (each side is a triangle):
[-4 0 5;
1 -5 5;
1 0 1;
1 5 5;
1 0 0]
How can I calculate it's volume?
I couldn't quite understand this answer.
  5 件のコメント
Adam Danz
Adam Danz 2019 年 11 月 21 日
編集済み: Adam Danz 2019 年 11 月 21 日
Even if I flip the z axis in my figure, it still doesn't produce the pyramid coordinates in the image in your comment above.
So, does your previous comment compute the volume of the pyramid would answers your question?
[update Re:PM]
Feel free to attach data to a comment or to your question. But more importantly, please clarify your question. Your code above seems to compute the volume so what problems are you having?
Hadi Ghahremannezhad
Hadi Ghahremannezhad 2019 年 11 月 21 日
Yes, because there are also faces and edges in the mesh alongside the vertices.
The code does not compute the volume. The last comment is the part that I need to use the vertex positions to compute the volume of the whole mesh and put it in vol.

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

採用された回答

Ridwan Alam
Ridwan Alam 2019 年 11 月 21 日
編集済み: Ridwan Alam 2019 年 11 月 21 日
Untitled1.png
Not quite sure I understood the problem. Yet, a hunch:
vertices = [-4 0 5;
1 -5 5;
1 0 1;
1 5 5;
1 0 0];
g = []; N = [];
for k = 1:size(vertices,1)
g = [g, sum(vertices(k,:))/3];
a = abs(vertices(k,1)-vertices(k,2));
b = abs(vertices(k,1)-vertices(k,3));
N = [N, a*b*sin(pi/3)]; % assuming theta = pi/3
end
Volume = sum(g.*N)/6;
  2 件のコメント
Hadi Ghahremannezhad
Hadi Ghahremannezhad 2019 年 11 月 21 日
Do you know what the logical and sign means between two vectors? Is that the normal of two vectors?
Ridwan Alam
Ridwan Alam 2019 年 11 月 21 日
編集済み: Ridwan Alam 2019 年 11 月 21 日
I believe that meant cross product of two vectors;
A ^ B = |A| |B| sin[theta]
Btw, please vote up if you liked the conversation!

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange3-D Volumetric Image Processing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by