How to create 3D volume plot of curved object with thickness

5 ビュー (過去 30 日間)
Shawn Cheng
Shawn Cheng 2021 年 11 月 2 日
コメント済み: Shawn Cheng 2021 年 11 月 15 日
Hello all,
I am trying to create a volume that looks like it is part of a pipe in 3D. Currently with my limited ability, the best i can do is to draw a partial outline of the object, and iterate multiple times to create an appearance of depth. However i would like to know how can i best describe this as a proper surface.
parCircle(0,0,0,100,10,30)
function parCircle(x,y,azipos,range,drange,dazi)
degtorad = pi / 180;
lookangle = 10 * degtorad;
incl = 45 * degtorad;
theta = (2*pi-lookangle-incl):lookangle/10:(2*pi-incl);
for i = azipos-dazi:dazi/10:azipos+dazi
x_f = x + (range + drange)* cos(theta);
y_f = y + (range + drange)* sin(theta);
azipos_f = i + zeros(size(x_f));
x_n = x + (range - drange)* cos(theta);
y_n = y + (range- drange)* sin(theta);
azipos_n = i + zeros(size(x_f));
plot3(azipos_f, x_f, y_f,'b');
plot3(azipos_n, x_n, y_n,'r');
end
end
The result of this code is multiple partial circle which forms a top and bottom 'suface' not an actual volume.

採用された回答

Abhiroop Rastogi
Abhiroop Rastogi 2021 年 11 月 11 日
Hi Shawn,
As can be seen from the figure provided in the question, the edges of the top and the bottom surface will serve as the boundaries for the surface enclosing the volume of the pipe. The data points for the boundaries can be stored in the variables "X_Temp", "Y_Temp", and "Z_Temp", as shown below. After which we can use the "surf" function to plot the surface required, and the resultant volume of the pipe will appear as shown below.
parCircle(0,0,0,100,10,30)
function parCircle(x,y,azipos,range,drange,dazi)
degtorad = pi / 180;
lookangle = 10 * degtorad;
incl = 45 * degtorad;
theta = (2*pi-lookangle-incl):lookangle/10:(2*pi-incl);
% introducing new variables
X_F = []; X_N = [];
Y_F = []; Y_N = [];
aZiPos_F = []; aZiPos_N = [];
for i = azipos-dazi:dazi/10:azipos+dazi
x_f = x + (range + drange)* cos(theta);
y_f = y + (range + drange)* sin(theta);
azipos_f = i + zeros(size(x_f));
X_F = [X_F,x_f'];
Y_F = [Y_F,y_f'];
aZiPos_F = [aZiPos_F,azipos_f'];
x_n = x + (range - drange)* cos(theta);
y_n = y + (range- drange)* sin(theta);
azipos_n = i + zeros(size(x_f));
X_N = [X_N,x_n'];
Y_N = [Y_N,y_n'];
aZiPos_N = [aZiPos_N,azipos_n'];
end
% "xx_F" represents the coordinates of bottom surface
% "xx_N" represents the coordinates of top surface
X_Temp = [X_F(1,:),X_F(:,end)',flip(X_F(end,:)),flip(X_F(:,1)');...
X_N(1,:),X_N(:,end)',flip(X_N(end,:)),flip(X_N(:,1)')];
Y_Temp = [Y_F(1,:),Y_F(:,end)',flip(Y_F(end,:)),flip(Y_F(:,1)');...
Y_N(1,:),Y_N(:,end)',flip(Y_N(end,:)),flip(Y_N(:,1)')];
Z_Temp = [aZiPos_F(1,:),aZiPos_F(:,end)',flip(aZiPos_F(end,:)),flip(aZiPos_F(:,1)');...
aZiPos_N(1,:),aZiPos_N(:,end)',flip(aZiPos_N(end,:)),flip(aZiPos_N(:,1)')];
figure()
plot3(aZiPos_F, X_F, Y_F,'b');
hold on
plot3(aZiPos_N, X_N, Y_N,'r');
surf(Z_Temp,X_Temp,Y_Temp)
hold off
grid on
end
You can modify the shape of the pipe by adding more boundaries to the surface, where, the boundaries represent the edges of various cross sections of the pipe.
  1 件のコメント
Shawn Cheng
Shawn Cheng 2021 年 11 月 15 日
This was a great read, appreciate your help !

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Segmentation and Analysis についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by