How to calculate the volume of a 3D triangular mesh?
    16 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Hadi Ghahremannezhad
 am 21 Nov. 2019
  
    
    
    
    
    Bearbeitet: Ridwan Alam
      
 am 21 Nov. 2019
            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?
5 Kommentare
  Adam Danz
    
      
 am 21 Nov. 2019
				
      Bearbeitet: Adam Danz
    
      
 am 21 Nov. 2019
  
			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?
Akzeptierte Antwort
  Ridwan Alam
      
 am 21 Nov. 2019
        
      Bearbeitet: Ridwan Alam
      
 am 21 Nov. 2019
  
      
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 Kommentare
  Ridwan Alam
      
 am 21 Nov. 2019
				
      Bearbeitet: Ridwan Alam
      
 am 21 Nov. 2019
  
			I believe that meant cross product of two vectors; 
A ^ B = |A| |B| sin[theta]
Btw, please vote up if you liked the conversation!
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!








