how can calculate irragular shape volume

2 views (last 30 days)
Mehmet demir
Mehmet demir on 22 Oct 2020
Answered: Star Strider on 22 Oct 2020
Hi! I want to calculate volume srfShape. I tried cunvhull and alphashape and voxel but i coudn't make this. Can you help me?

Answers (1)

Star Strider
Star Strider on 22 Oct 2020
Experiment with this approach:
F1 = openfig('surfShape.fig');
Surfc = F1.Children.Children;
X = Surfc.XData;
Y = Surfc.YData;
Z = Surfc.ZData;
ElementProduct = prod(cat(3,X,Y,Z),3); % Products Of Corresponding Elements Of Matrices
ApproxVol = trapz(trapz(ElementProduct)) / (numel(X)*3); % Integrate Result
Using an indirect check on the results (a cube with the limits of the elements):
[XL,XH] = bounds(X,'all'); % Check Results
[YL,YH] = bounds(Y,'all'); % Check Results
[ZL,ZH] = bounds(Z,'all'); % Check Results
Check = prod(diff([XL XH; YL YH; ZL ZH],[],2)) % Check Results
produces:
ApproxVol =
9.395695811724738e+03
and:
Check =
9.635124211073383e+04
I do not understand the reason that the calculated volume and the upper limit of the possible volume are off by a factor of 10, other than that the ‘Check’ is obviously going to be larger since it uses the limits of the element values. I expected the difference to be less. This approach is somewhat empirical, since I have not encountered this sort of problem previously.

Products


Release

R12.1

Community Treasure Hunt

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

Start Hunting!