無聊,繪正方體

來源:互聯網
上載者:User

標籤:color   io   os   ar   for   on   amp   ad   size   

clc;
clear all;
close all;

%% 畫長方體% --------------xy底面---------------
x = -10:1:10;
y = x;
[x,y]=meshgrid(x,y);
z = -10*ones(size(x));
p1 = surf(x,y,z);
shading interp
alpha(0.6)
hold on
% --------------xz側面---------------
x = -10:1:10;
z = x;
[x,z]=meshgrid(x,z);
y = -10*ones(size(x));
surf(x,y,z);
shading interp
alpha(0.6)
% --------------xz側面---------------
x = -10:1:10;
z = x;
[x,z]=meshgrid(x,z);
y = 10*ones(size(x));
surf(x,y,z);
shading interp
alpha(0.6)
% --------------yz側面---------------
y = -10:1:10;
z = y;
[y,z]=meshgrid(y,z);
x = 10*ones(size(y));
surf(x,y,z);
shading interp
alpha(0.6)
% --------------yz側面---------------
y = -10:1:10;
z = y;
[y,z]=meshgrid(y,z);
x = -10*ones(size(y));
surf(x,y,z);
shading interp
alpha(0.6)
%-----------波面----------------------------------
x = -10:1:10;
y = x;
[x,y]=meshgrid(x,y);
z = ones(size(x));
p1 = surf(x,y,z);
set(p1,‘FaceColor‘,‘b‘);
shading interp
alpha(0.6)
hold on
%-----------魚糞----------------------------------
% rand(‘seed‘,0);
x = 10*(2*rand(1,4) - 1);
y = 10*(2*rand(1,4) - 1);
z = rand(1,4) - 9;
plot3(x,y,z,‘kh‘,‘MarkerFaceColor‘,‘k‘,‘markersize‘,12);
%-----------魚料---------------------------------
x = 10*(2*rand(1,4) - 1);
y = 10*(2*rand(1,4) - 1);
dx = rand;
dy = rand;
z = rand(1,4)-1 ;
dz = rand;
plot3([x,x+dx],[y,y+dy],[z,z+dz],‘mo‘,‘MarkerFaceColor‘,‘m‘,‘markersize‘,14);
%-----------------------小魚-------------------------
xx = 10*(2*rand - 1);
yy = 10*(2*rand - 1);
zz =-5*rand ;
p2 =plot3(xx,yy,zz,‘ro‘,‘MarkerFaceColor‘,‘r‘,‘markersize‘,22);
tem = 1000;
for i= 1:1000
dx =unifrnd(-1,1);
dy = unifrnd(-1,1);
dz = unifrnd(-1,1);
temz1 = -9;
temz2 = -1;
temx1 = -9;
temx2 = 9;
temy1 = -9;
temy2 = 9;
if ( zz > temz1)&& (zz < temz2)
if ( xx> temx1)&& (xx < temx2)
if ( yy > temy1)&&(yy < temy2)
xx = xx + dx;
yy = yy + dy;
zz = zz + dz;
set(p2,‘xdata‘,xx,‘ydata‘,yy,‘zdata‘,zz);
end
end
elseif ( zz >temz1)&& (zz < temz2) &&( xx>temx1)&& (xx < temx2)
xx = xx +dx;
yy = yy - dy;
zz = zz +dz;
set(p2,‘xdata‘,xx,‘ydata‘,yy,‘zdata‘,zz);
elseif ( zz >temz1)&& (zz < temz2) &&( yy >temy1)&& (yy < temy2)
xx = xx -dx;
yy = yy + dy;
zz = zz +dz;
set(p2,‘xdata‘,xx,‘ydata‘,yy,‘zdata‘,zz);
elseif ( xx>temx1)&& (xx < temx2)&&( yy >temy1)&& (yy< temy2)
xx = xx +dx;
yy = yy + dy;
zz = zz -dz;
set(p2,‘xdata‘,xx,‘ydata‘,yy,‘zdata‘,zz);
else
continue
end
tem = tem -1;
pause(0.1)
drawnow

end
% while
% [y,fs] =audioread(‘2865a93400.mp3‘);
% sound(y, fs);
% end

無聊,繪正方體

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.