How to calculate the volume enclosed by a set of XYZ points in 3D?

71 ビュー (過去 30 日間)
Sourav Sahoo
Sourav Sahoo 2021 年 1 月 23 日
コメント済み: Bruno Luong 2022 年 6 月 17 日
Hi,
I am trying to find the volume of a region (defined by X,Y and Z coordinates) enclosed below a (Z='constant') plane. The data has peaks (positive Z) and a valley (negative Z), and the mean surface is assigned z=0. I have tried with the following piece of code, but I doubt it gives me the total volume bound by the surface against z=0, including the peak volumes as well.
[X,Y,Z] = xyzread("data.xyz");
plot3(X,Y,Z)
[fitobject, gof, output] = fit([X,Y],Z, 'biharmonicinterp');
plot(fitobject)
a = min(X);
b = max(X);
c = min(Y);
d = max(Y);
volume_under_fit = quad2d(fitobject,a,b,c,d)

採用された回答

Bruno Luong
Bruno Luong 2021 年 1 月 23 日
編集済み: Bruno Luong 2021 年 1 月 23 日
V is the volume between the plane x-y (z==0) and the surface z(x,y) from your data.
If you want the volume of the data after substract the base plane surface, you need to estimated the equation by regression.
load('data.xyz')
x=data(:,1);
y=data(:,2);
z=data(:,3);
T=delaunay(x,y);
trisurf(T,x,y,z);
xy = [x,y];
a = xy(T(:,2),:)-xy(T(:,1),:);
b = xy(T(:,3),:)-xy(T(:,1),:);
V = ((a(:,1).*b(:,2)-a(:,2).*b(:,1))' * sum(z(T),2))/6
  5 件のコメント
Lyhour Chhay
Lyhour Chhay 2022 年 6 月 16 日
Dear Bruno Luong and Sourav Sahoo,
First of all, I really interest your approach to calculate the volme. I have a problem similar to a proposed problem. I have point cloud with x,y,z data. I want to find the volume between the plan x-y (z==5) and my point cloud data. I will show in the figure below. how can I solve this problem ? I tried to use the code in the comment, it show the negative value for my result. thank you very much.
Bruno Luong
Bruno Luong 2022 年 6 月 17 日
If you want to adapt the above code plane z=5 and you data is bellow the plane then change to
x=data(:,1);
y=data(:,2);
z=5-data(:,3);
and do the rest similarly.

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 1 月 23 日
編集済み: Walter Roberson 2021 年 1 月 23 日

カテゴリ

Help Center および File Exchange3-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