Matlab 版 (精华区)
发信人: zjliu (秋天的萝卜), 信区: Matlab
标 题: [转载]关税15
发信站: 哈工大紫丁香 (Thu Jun 12 21:30:51 2003)
function x=rotcube2()
x=[0 1 1 0 0 0 1 1 0 0 NaN 1 1 NaN 1 1 NaN 0 0];
y=[0 0 1 1 0 0 0 1 1 0 NaN 0 0 NaN 1 1 NaN 1 1];
z=[0 0 0 0 0 1 1 1 1 1 NaN 1 0 NaN 0 1 NaN 1 0];
cube_h=plot3(x-0.5,y-0.5,z-0.5);
axis('square');
axis([-1 1 -1 1 -1 1]*2);
view(-37.5,15);
set(cube_h,'erasemode','background');
rotation_increment=5;
rotation_axis=[0 0 1];
rotation_origin=[0 0 0];
num_of_incr=360/rotation_increment;
pause(2)
for loop=1:num_of_incr
rotate(cube_h,rotation_axis,...
rotation_increment,rotation_origin);
drawnow;
end
refresh
pause(2)
cube2_h=line(x+1,y+1,z+1,'erasemode','background');
for loop=1:num_of_incr
rotate(cube2_h,rotation_axis+[1 1 0],...
rotation_increment,rotation_origin+1);
drawnow;
end
refresh
pause(2)
x=[0 0 1 1 0];y=[0 1 1 0 0];z=zeros(size(x));
rotation_axis=[0 0 1];
rotation_origin=[0 0 0];
num_of_incr=360/rotation_increment;
s1_h=surf([x;x]-.5,[y;y]-.5,[z+0.5;z-0.5]);
set(s1_h,'erasemode','background',...
'facecolor','none',...
'edgecolor','g');
s2_h=surface([x;x]+1.5,[y;y]+1.5,[z+.5;z-0.5]+1.5,...
'erasemode','background',...
'facecolor','g',...
'edgecolor','r');
s3_h=surface([x;x]+1.5,[y;y]+1.5,[z+.5;z-0.5],...
'erasemode','background',...
'facecolor','r',...
'edgecolor','b');
axis([-3 3 -3 3 -3 3]);axis('square');
for loop=1:num_of_incr
rotate(s1_h,rotation_axis,...
rotation_increment,rotation_origin);
rotate(s2_h,rotation_axis+[1 1 0],...
rotation_increment,rotation_origin+1);
rotate(s3_h,rotation_axis,...
rotation_increment,rotation_origin);
drawnow
end
refresh
练习:
1 facecolor 是起什么作用的?
--
╔═══════════════════╗
║★★★★★友谊第一 比赛第二★★★★★║
╚═══════════════════╝
※ 来源:.哈工大紫丁香 bbs.hit.edu.cn [FROM: 202.118.229.92]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.055毫秒