matlab 中的 3D 立方体

问题描述

这是我在 Malab 中的代码

clear all
close all
colores = ['b','y','g','r','c','k'];

nCubos=6;
cubos=cell(1,nCubos);
cubos{1}(60:140,70:150,70:150) =0.6;
cubos{2}(107:177,151:221,90:160) =0.6;
cubos{3}(80:150,160:230,161:231) =0.6;
cubos{4}(153:183,193:223,161:181) =0.6;
cubos{5}(57:97,160:200,120:160) =0.6;
cubos{6}(130:180,132:182,161:211) =0.6;

cubos{3}=imrotate(cubos{3},40,'crop');

for p=1:nCubos
    color = colores(mod(p,length(colores))+1);
    disp(color)
    [x,y,z] = ind2sub(size(cubos{p}),find(cubos{p}));
    plot3(x,z,'color',color,'marker','.')
    pause(0.01)
    hold on;
    axis([0 256 0 256 0 256]);
end
hold off; 

这是输出

enter image description here

我想在每次执行程序时创建这样的随机立方体,具有不同的大小和位置而不重叠,但在一个面或一个顶点相交。

谢谢!!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)