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.?

1 次查看(过去 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