2007年3月27日 星期二

作業四

B94611008 生機二 徐嘉鴻
4.1
axis equal;
axis([-20 40 -20 40])
lenth=8+10; %三角形邊長
triangle=[0 0;lenth 0;lenth/2 3^(1/2)*lenth/2;0 0]
tri_P=line(triangle(:,1),triangle(:,2)) %畫三角形
for n=1:180; %以頂點旋轉
rotate(tri_P,[0 0 1],2,[0 0 0])
pause(0.002)
end
for n=1:180; %以頂點旋轉
rotate(tri_P,[0 0 1],2,[lenth 0 0])
pause(0.002)
end
for n=1:180; %以頂點旋轉
rotate(tri_P,[0 0 1],2,[lenth/2 3^(1/2)*lenth/2 0])
pause(0.002)
end
%將程式碼以MATLAB啟動將出現動畫

4.2
for n=0:17
x=10*cosd(20*n); %連桿一端之X值
y=10*sind(20*n); %連桿一端之Y值
linkshape([0 0],[x y],4)%繪製連桿
line([15 x],[0 y])%連桿一端與彈簧的連接
end


4.3
PART 1 四連桿位置
axis equal
linkshape([0 0],[10 0],2);%第一桿
linkshape([0 0],[3 4],3);%第二桿
linkshape([3 4],[13 4],1.5);%第三桿
linkshape([13 4],[10 0],2);%第四桿


PART 2 每間隔30度間之對應位置
linkshape([0 0],[10 0],2); %AD固定桿
for n=1:12
start=atand(4/3);
Bx=5*cosd(start+30*n); %B端X值
By=5*sind(start+30*n); %B端Y值
linkshape([0 0],[Bx By],3); %AB桿
linkshape([Bx By],[Bx+10 By],1.5);%BC桿
linkshape([Bx+10 By],[10 0],2); %CD桿
pause(0.005)
end

沒有留言: