How to divide the object cone into layers (e.g. slices) of certain thickness(e.g. thickness = 10 or 5 ...) to measure it volume layers-wise.?

조회 수: 4 (최근 30일)
I have a cone. I measured its volume using code below. very thankful to Mr. Bruno Luong for his guidance. My aim is to divide this cone into number of layers using certians thickness, then i want to measure the volume of each layer (i.e. slice). For example, using thickness of layers = 10, i will get certain numer of layers (i.e. slices). How can we perform such operations using matlab. Thanks in advance for all cooperation.
Attached is file for coordinates of the cone using following cone parameters.
% Cone parameters
% x, y, and z coordinates are given in attached file.
R = 78; % radius of the cone
h = 188.4; % height of the cone.
N = 20000; % points used to generate the cone.
tri = delaunay(x,y,z);
trisurf(tri,x,y,z)
% indices of triangle
i1 = tri(:,1);
i2 = tri(:,2);
i3 = tri(:,3);
i4 = tri(:,4);
%% Volume by summing tetrahedron
v1 = [x(i1)-x(i2) y(i1)-y(i2) z(i1)-z(i2)];
v2 = [x(i1)-x(i3) y(i1)-y(i3) z(i1)-z(i3)];
v3 = [x(i1)-x(i4) y(i1)-y(i4) z(i1)-z(i4)];
A = 1/2*cross(v1,v2,2); % surface of a triangle
V = 1/3*dot(A,v3,2); % volume of a tetrahedron
format longG
V = sum(abs(V))
  댓글 수: 3
M.S. Khan
M.S. Khan 2020년 8월 27일
Hi KSSV, i want to plot the cone and then want to divide it into layers of certain thickness then i want to measure volume of each layer. Finally, volume of all layers will give volume of the cone. Could you plz guide me.

댓글을 달려면 로그인하십시오.

채택된 답변

Bruno Luong
Bruno Luong 2020년 8월 31일
편집: Bruno Luong 2020년 8월 31일
Among the methods that you request , this one is the worst method.
R = 78;
h = 188.4000;
Vtheoretical = pi*R^2*h/3 % 1200324.64
load('xyz_coords_cone.txt');
z = xyz_coords_cone(:,3);
dz = 10; % WARNING: chosen carefully the step depending on the desity of points, otherwise inaccurate result returned
zbin = min(z):dz:max(z);
zbin(end) = Inf;
[n, loc] = histc(z, zbin);
nbins = length(n);
s = zeros(1,nbins);
for k=1:nbins
xy = xyz_coords_cone(loc==k,[1 2]);
if ~isempty(xy)
[~,s(k)] = convhull(xy);
end
end
V = sum(s)*dz % 1195520.00
  댓글 수: 1
M.S. Khan
M.S. Khan 2020년 9월 1일
Thanks Bruno for your kind support and time. Yes, your warning is correct. i have tested using i.e. dz = 5, it shows difference with theoratical volume about 50244. For dz =15, it showd difference of about -53915. you are right, it is due to density of points. if we increase the number of points, can we decrease the gap of the differenc between volumes. Regards

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 3-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