3D Surface of revolution from a 2D perimeter

7 Ansichten (letzte 30 Tage)
Claud
Claud am 31 Mär. 2023
Kommentiert: Claud am 1 Apr. 2023
Hi everyone,
I am trying to create a surface of revolution with respect to the y-axis of the 2D geometry I have plotted in the attached image. To do so, I have generated the arrays of the x- and y-values of the lines that I used to plot the contours for the 2D geometry (considering only the quadrants where x>0 such that it can be rotated by 360° to obtain a closed geometry). However, I am struggling to find a simple method to create the surface of rotations for all the closed segments and to merge the results into an stl file. For example, the circles should become tori, the rectangular payload should become a cylinder, and the overall shape should be that of a HIAD (as indicated in the image attached). I also attached the script with the x- and y- arrays for each closed set of curves.
I would appreciate any help
  2 Kommentare
Claud
Claud am 31 Mär. 2023
Quads would be ideal if possible!

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

John D'Errico
John D'Errico am 1 Apr. 2023
Bearbeitet: John D'Errico am 1 Apr. 2023
Ok. (I should probably write code to do this in general, for any arbitrary polygon.)
Quad elements. I'll show how to do it for a circle, in the (x,y) plane, then rotated around the x axis.
nt = 100;
t = linspace(0,2*pi,nt).'; % I want this as a column vector
C = [2 3]; % the center of the circle in the (x,y) plane.
R = 1; % radius 1
xy = C + R*[cos(t), sin(t)]; % points in the circle
plot(xy(:,1),xy(:,2),'r-')
axis equal % makes it show up as a circle
nphi = 200; % 100 elements around the axis.
phi = linspace(0,2*pi,nphi + 1); % 100 elements means that we need to have 101 points in the surface of revolution
Next, we need to create a 2-d mesh. I'll use ndgrid. meshgrid would work too. The mesh will be parameterized in terms of t and phi.
[T,PHI] = ndgrid(t,phi);
[subt,subphi] = ndgrid(1:nt-1,1:nphi-1);
ind = sub2ind([nt,nphi],subt,subphi);
ind = ind(:);
rectess = [ind,ind+1,ind+nt,ind+nt+1]; % quad elements
Now build the nodes in (x,y,z), by rotating the circle around the x axis.
X = (C(1)+R*cos(T)).*cos(PHI); % Multiply the original x by cos(phi)
Y = (C(2)+R*sin(T)); % Leave Y alone
Z = (C(1)+R*cos(T)).*sin(PHI); % Multiply the original x by sin(phi) to create the Z component
surf(X,Y,Z)
axis equal
box on
xlabel X
ylabel Y
zlabel Z
So, a circle in the (x,y) plane, rotated around the x-axis. Each row of rectess corresponds to one quad element. The only problem that remains is the nodes should wrap around. Essentially, we have nodes that are repeated in that tessellation. The first quad element in the list was:
rectess(1,:)
ans = 1×4
1 2 101 102
But some of the quads need to be fixed, because the first node in the circle is also the last node. To make this a valid tessellation, without those duplicated elements, we need to treat those duplicated nodes properly.
[R,C] = ind2sub([nt,nphi],rectess);
R(R == nt) = 1;
C(C == nphi) = 1;
rectess = sub2ind([nt,nphi],R,C);
And now the last quad element in the list is:
rectess(end,:)
ans = 1×4
19899 19801 99 1
That should work.
  3 Kommentare
Claud
Claud am 1 Apr. 2023
Thank you very much, you have been extremely helpful. I now fully understand the idea behind the code.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by