3D Surface of revolution from a 2D perimeter
6 views (last 30 days)
Show older comments
Commented: Claud on 1 Apr 2023
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
John D'Errico on 1 Apr 2023
Edited: John D'Errico on 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
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
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:
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:
That should work.
More Answers (0)
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!