How to calculate the size of 3D data (several sections)

5 visualizzazioni (ultimi 30 giorni)
Hi
I have a set of slices (sections). Each section boundary is described by 3D data. The sections together build an unregular geometry. I wonder if there is any relatively accurate method capable of calculating the total volume of the unregular geometry. I tried the convex hull method, but it gave me an error that goes by 40%.
Thank you
Aziz

Risposte (1)

Avni Agrawal
Avni Agrawal il 15 Feb 2024
I understand that calculating the volume of an irregular 3D geometry composed of multiple sections can be challenging, especially if the sections are non-planar and the geometry is complex. The convex hull method gives you the volume of the smallest convex shape that can contain all your points, which can be significantly larger than the actual volume if the shape is concave or has internal structures.
Here is the method that you can consider to calculate the volume more accurately:
Triangulation Method:
- Triangulate each section to create a mesh of triangles that approximate the section's boundary.
- Stack the triangulated sections to form a 3D mesh.
- Decompose the 3D mesh into tetrahedra.
- Calculate the volume of each tetrahedron and sum them up to get the total volume.
Here is a simplified MATLAB example using this method:
% Assuming 'sections' is a cell array where each cell contains
% a matrix of 3D points [x, y, z] that define the boundary of each section
sections = {...}; % Your section boundary data
% Initialize total volume
totalVolume = 0;
% Loop through section pairs and calculate the volume between them
for i = 1:length(sections)-1
% Get the current and next section
currentSection = sections{i};
nextSection = sections{i+1};
% Assume that the sections have the same number of points and the points
% correspond to each other. If not, you'll need to interpolate or match points.
% Calculate the volume between the current and next section
for j = 1:size(currentSection, 1)-1
% Define the vertices of a prism (two triangles with a shared edge)
p1 = currentSection(j, :);
p2 = currentSection(j+1, :);
p3 = nextSection(j, :);
p4 = nextSection(j+1, :);
% Split the prism into two tetrahedra and calculate their volumes
tetra1 = [p1; p2; p3; p4];
tetra2 = [p2; p3; p4; nextSection(j, :)];
% Use the determinant method to calculate the volume of each tetrahedron
vol1 = abs(det([tetra1'; ones(1, 4)]))/6;
vol2 = abs(det([tetra2'; ones(1, 4)]))/6;
% Add the volumes to the total
totalVolume = totalVolume + vol1 + vol2;
end
end
% Output the total volume
disp(['Total Volume: ', num2str(totalVolume)]);
This code assumes that each section contains the same number of points and that the points in each section correspond to the points in the next section. If this is not the case, you would need to implement a point matching or interpolation scheme. The 'det' function is used here to calculate the volume of each tetrahedron using the determinant method.
I hope this helps.

Categorie

Scopri di più su Bounding Regions in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by