Hey guys, my stlwrite function is not working and i would like to know how to fix it. In the code C is random points

2 views (last 30 days)
Akshay Kumar Pakala
Akshay Kumar Pakala on 24 Mar 2022
Commented: Rik on 25 Mar 2022
seeds=C;
Unrecognized function or variable 'C'.
[Ver,Cel,C_tst]=voronoi3d_cuboid(seeds,Vcub);
FK = zeros(100,3,312);
figure
hold on
axis('equal')
view([-36 27])
scatter3(seeds(:,1),seeds(:,2),seeds(:,3),25, ...
'Marker','o','MarkerFaceColor',[1 0 0], 'MarkerEdgeColor','k');
scatter3(Ver(:,1),Ver(:,2),Ver(:,3),25, ...
'Marker','o','MarkerFaceColor',[0 1 0], 'MarkerEdgeColor','r');
for k = 1:length(Cel)
if ~isempty(Cel{k})
col=rand(1,3);
Vk = Ver(Cel{k},:); Fk = convhull(Vk);
if exist('mergeCoplanarFaces.m','file')==2
[Vk, Fk] = mergeCoplanarFaces(Vk, Fk);
for i=1:length(Fk)
patch('Vertices',Vk,'Faces',Fk{i},'FaceColor',col,'FaceAlpha',0.3)
end
else
trisurf(Fk,Vk(:,1),Vk(:,2),Vk(:,3),'FaceColor',col, ...
'FaceAlpha', 1,'EdgeAlpha',1,'EdgeColor','k');
%
FK(1:size(Fk,1),1:3,k) = Fk(:,1:3);
VK(1:size(Vk,1),1:3,k) = Vk(:,1:3);
end
end
end
grid on
xlabel('X');ylabel('Y');zlabel('Z');
P = struct('faces',FK,'vertices',VK);
stlwrite('mytriangulation.stl',P);

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by