2007年3月28日 星期三

機動學第四週作業

第一題
function link_rot2(v)
if nargin==0,v=50;end
r=7.5;d=2;
X=[0,15,15/2,0];Y=[0,0,15*0.5*(3)^0.5,0];
delt=pi/120;axis image;axis off;
h1=line(X,Y,'erasemode','xor','color','r','linewidth',2);
x1=get(h1,'xdata');y1=get(h1,'ydata');
theta1=0;s1=delt;
while 1,
drawnow;
pause(1/v);
theta1=theta1+s1;
x2=(x1-7.5)*cos(theta1)-(y1-2.5*(3)^0.5)*sin(theta1)+7.5;
y2=(x1-7.5)*sin(theta1)+(y1-2.5*(3)^0.5)*cos(theta1)+2.5*(3)^0.5;
set(h1,'xdata',x2,'ydata',y2);
if theta1>2*pi,theta1=theta1-2*pi;end;
end
第二題
function link_rot3(v)
if nargin==0,v=50;end
[x,y]=links([0 0],[10,0],4);
a=[10,15];b=[0,0];delt=pi/120;
axis equal;t=0:2*pi/50:2*pi;
h1=line(x,y,'erasemode','xor','color','r','linewidth',2);
line1=line(a,b,'erasemode','xor');
x1=get(h1,'xdata');y1=get(h1,'ydata');
theta1=0;s1=delt;
while 1,
drawnow;
pause(1/v);
theta1=theta1+s1;
x2=x1*cos(theta1)-y1*sin(theta1);
y2=x1*sin(theta1)+y1*cos(theta1);
a2=[10*cos(theta1),15];
b2=[10*sin(theta1),0];
set(h1,'xdata',x2,'ydata',y2);
set(line1,'xdata',a2,'ydata',b2);
if theta1>2*pi,theta1=theta1-2*pi;end;
end
第三題
function link_plot2(x,y,w)
clf;
if nargin==2,w=1;end
for i=1:length(x)-1
linkshape([x(i) y(i)],[x(i+1) y(i+1)],w(i));end

function rotate(i)
if nargin==0,i=0,end
link_plot2([0,5*cos(pi/6*i+acos(0.8)),10+5*cos(pi/6*i+acos(0.8)),10,0],[0,5*sin(pi/6*i+acos(0.8)),5*sin(pi/6*i+acos(0.8)),0,0],[3,1.5,2,2]);

1 則留言:

不留白老人 提到...

結果呢?你的姓名及學號呢?