
Cylindrical ring of implicit surfaces
조회 수: 7 (최근 30일)
이전 댓글 표시
Dear community,
currently I try to model a cylindrical ring of implicit surfaces. Basically I found a solution for this, but unfortunately there appears a problem at the transition areas: First, these are not completely smooth and second, there are surplus surfaces there because of the isocaps.
Up to now I have proceeded in such a way that I first create a unit cell and then multiply and transform it until the ring is closed.
Below is a picture of a stl-file of my previous result and the corresponding code.
Does anyone have an idea to solve my problems (especially when combining the individual surfaces, or a possibility for preparation) or an alternative suggestion for creating such a structure where the problem does not occur?
Thanks a lot already and best regards

clc
clear
close all
n=80;
t=pi/n;
x_max=1;
y_max=1;
z_max=1;
r_max=4;
num=12;
factor=6.4/num;
xi = -x_max/2:t:x_max/2;
yi = -y_max/2:t:y_max/2;
zi = -z_max/2:t:z_max/2;
[x,y,z] = meshgrid(xi,yi,zi);
F=cos(2.*pi.*x)+cos(2.*pi.*y)+cos(2.*pi.*z);
% First body
[fs,v]=isosurface(x,y,z,F,0);
v(:,2)=v(:,2)+r_max;
[~,rho] = cart2pol(v(:,1),v(:,2));
theta=v(:,1).*factor;
[v(:,1),v(:,2)] = pol2cart(theta,rho);
[fc,v2,c] = isocaps(x,y,z,F,0);
v2(:,2)=v2(:,2)+r_max;
[~,rho] = cart2pol(v2(:,1),v2(:,2));
theta=v2(:,1).*factor;
[v2(:,1),v2(:,2)] = pol2cart(theta,rho);
fn = [fs ; fc+length(v(:,1))];
vn = [v ; v2];
fges=fn;
vges=vn;
% Further bodies
for i=1:Zellanzahl-1
phi=(i*2*pi)/(num);
R=[cos(phi) -sin(phi) 0;sin(phi) cos(phi) 0;0 0 1];
for j=1:length(vn(:,1))
viteration(j,:)=R*vn(j,:)';
end
fiteration = fn+i*max(max(fn));
fges = [fges ; fiteration];
vges = [vges ; viteration];
end
stlwrite('geometry.stl',fges,vges);
댓글 수: 0
답변 (2개)
Kamal Uddin Mohammad Miah
2021년 9월 1일

Hallo Fabian, this pictuer might help you to write the code, i am new in programming as well as working in the same direction.
Ref: Numerical and experimental studies on compressive behavior of Gyroid
lattice cylindrical shells
Yongzhen Wang a,d, Xianben Ren a, Zihao Chen b, Yongbo Jiang b, Xiaofei Cao a, Shizheng Fang c, Tian Zhaoa,b,⁎,
Ying Li a,b,⁎, Daining Fanga,b
댓글 수: 0
DGM
2025년 7월 5일
편집: DGM
2025년 7월 5일
I think part of the unevenness is because you're using the colon operator to set up your meshes. When you do that, you need to make sure that your interval is integer-divisible by the step size, otherwise you risk not including the endpoint of your interval. In this case, your intervals were all [-0.5 0.4817] instead of [-0.5 0.5], making things slightly lopsided. Use linspace(). I think the other problem might be the value used for factor.
Get rid of the internal geometry before combining it with everything else. Finally, get rid of the near-duplicate points at the seams in order to close the surface.
% parameters
nsamp = 25;
x_max = 1;
y_max = 1;
z_max = 1;
r_max = 4;
num = 12;
factor = 2*pi/num; % ??
% use linspace to make sure endpoints are included!
xi = linspace(-x_max/2,x_max/2,nsamp);
yi = linspace(-y_max/2,y_max/2,nsamp);
zi = linspace(-z_max/2,z_max/2,nsamp);
[x,y,z] = meshgrid(xi,yi,zi);
F = cos(2.*pi.*x)+cos(2.*pi.*y)+cos(2.*pi.*z);
% First body ---------------------------------
[fs,v] = isosurface(x,y,z,F,0); % the initial shape
[fc,vc] = isocaps(x,y,z,F,0); % the initial caps
mask = abs(abs(vc(:,1))-0.5) <= 1E-6; % select the caps where segments meet
[fc,vc] = prunebadverts(fc,vc,~mask); % get rid of them
fn = [fs; fc + size(v,1)]; % combine them
vn = [v; vc];
% transform the body at once (i'm not going to question this)
vn(:,2) = vn(:,2) + r_max;
[~,rho] = cart2pol(vn(:,1),vn(:,2));
theta = vn(:,1).*factor;
[vn(:,1),vn(:,2)] = pol2cart(theta,rho);
% draw the segment
patch('faces',fn,'vertices',vn,'facecolor','w','edgecolor','none');
view(3); view(-150,21); camlight;
axis equal; grid on
xlabel('X'); ylabel('Y'); zlabel('Z')
% Further bodies ---------------------------------
fges = fn;
vges = vn;
nv = size(vn,1);
for k = 1:num-1
phi = (k*2*pi)/(num);
R = [cos(phi) -sin(phi) 0; sin(phi) cos(phi) 0; 0 0 1];
fges = [fges; fn + k*nv]; %#ok<*AGROW>
vges = [vges; vn*R];
end
% get rid of near-duplicate vertices at seams
[fges vges] = prunedupeverts(fges,vges,1E-9); % some appropriate tolerance
% draw the ring
figure
patch('faces',fges,'vertices',vges,'facecolor','w','edgecolor','none');
view(3); view(144,44); camlight;
axis equal; grid on
xlabel('X'); ylabel('Y'); zlabel('Z')
% write to a file
%stlWrite('geometry.stl',fges,vges); % FEX #20922 or #51200
stlwrite(triangulation(fges,vges),'geometry.stl') % built-in R2018b or newer
The extra tools I used are attached.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Biological and Health Sciences에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

