MATLAB Answers

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 view (last 30 days)
M.S. Khan
M.S. Khan on 27 Aug 2020
Commented: M.S. Khan on 1 Sep 2020
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 Comments

KSSV
KSSV on 27 Aug 2020
When you have radius and height, you can striaght aways plot a cone. Why you want to play with coordinates in text file? I literally did not understand what you are trying to do because I see that you have asked many questions on the same topic.
M.S. Khan
M.S. Khan on 27 Aug 2020
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.

Sign in to comment.

Accepted Answer

Bruno Luong
Bruno Luong on 31 Aug 2020
Edited: Bruno Luong on 31 Aug 2020
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 Comment

M.S. Khan
M.S. Khan on 1 Sep 2020
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

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!