Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Combine multiple implicit surfaces in a stl file
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dear community,
I am trying to write and export several simultaneously created implicit surfaces to a common stl file.
If I export the two surfaces separately I get two stl files with correct surfaces, but as soon as I combine the data in Matlab the second surface is "destroyed".
Enclosed are the images of the separately created and the common stl document and my code for the common variant.
Many thanks already and best regards
clc
clear
close all
n=60;
t=pi/n;
x_max=1;
y_max=1;
z_max=1;
r_max=6;
r_vor=2*pi*r_max;
factor=pi./6;
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).*sin(2.*pi.*y)+cos(2.*pi.*y).*sin(2.*pi.*z)+cos(2.*pi.*z).*sin(2.*pi.*x); % G
% 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;
[~,rho2] = cart2pol(v2(:,1),v2(:,2));
theta2=v2(:,1).*factor;
[v2(:,1),v2(:,2)] = pol2cart(theta2,rho2);
fn = [fs ; fc+length(v(:,1))];
vn = [v ; v2];
% Second body
[fs99,v99]=isosurface(x,y,z,F,0);
v99(:,2)=v99(:,2)+r_max;
[~,rho99] = cart2pol(v99(:,1),v99(:,2));
theta99=v99(:,1).*factor;
[v99(:,1),v99(:,2)] = pol2cart(theta99,rho99);
phi=30/360*2*pi;
R99=[cos(phi) -sin(phi) 0;sin(phi) cos(phi) 0;0 0 1];
for i=1:length(v99(:,1))
v99(i,:)=R99*v99(i,:)';
end
[fc99,v299,c99] = isocaps(x,y,z,F,0);
v299(:,2)=v299(:,2)+r_max;
[~,rho299] = cart2pol(v299(:,1),v299(:,2));
theta299=v299(:,1).*factor;
[v299(:,1),v299(:,2)] = pol2cart(theta299,rho299);
for i=1:length(v299(:,1))
v299(i,:)=R99*v299(i,:)';
end
fn99 = [fs99 ; fc99+length(v99(:,1))];
fn99 = fn99+max(max(fn));
vn99 = [v99 ; v299];
% Combinition and Output using function stlwrite
fnges = [fn ; fn99];
vnges = [vn ; vn99];
stlwrite('geometry.stl',fnges,vnges);
0 commentaires
Réponses (0)
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!