2007年5月16日 星期三

作業九

B94611016 胡寅亮

本人5月3日有來上課
我是五月十號下午兩點的那組

關於滑塊驅動,我的想法如下:

先求出曲桿跟滑塊的座標並連起來,再利用for迴圈製作動畫

要知道曲桿的座標,必須先知道曲桿跟水平夾角的極限值(th1、th2)
要知道滑塊的座標,必須先知道滑塊到原點的水平距離(d)以及偏置量(e)

th1、th2可由以下的function求出:
function [s,th1,th2]=slider_limit(R,L,e)
th1=asind(e./(R+L));
th2=180+asind((L-e)/R);
s=(R+L).*cosd(th1)-abs(R-L).*cosd(th2);

d可由以下的function求出:
function [d,theta3]=slider_solve(theta2,R,L,e,mode)
if nargin<5, mode=0;end
theta=theta2*d2g;
cc=(e-R.*sind(theta))./L;
if mode>=0,
theta3=asind(cc);
else
theta3=asind(-cc)+pi;
end
d=L.*cosd(theta3)+R.*cosd(theta);

因此我寫一個slider function說明曲桿的驅動方式如下,
function slider(R,L,e)

[s,th1,th2]=slider_limit(R,L,e)
th=linspace(th1,th2,300 )
[d,th3]=slider_solve(th,R,L,e,1)

x=R*cosd(th),
y=R*sind(th)
for n=1:300

line([0,x(n),d(n)],[0,y(n),e]);
line([d(n)-1,d(n)+1,d(n)+1,d(n)-1,d(n)-1],[e-3,e-3,e+3,e+3,e-3]);
ground(0,0,3,0)
anchor(-3,0,0,0)
pause(0.01);
axis ([-100 100 -100 100]);
axis equal;
clf;

end

關於滑塊驅動,我的想法如下:
建立一個function slider2
function slider2(R,L,e)

[s,th1,th2]=slider_limit(R,L,e)
th=linspace(th1,th2,300 )
[d,th3]=slider_solve(th,R,L,e,1)

x=R*cosd(th)
y=R*sind(th)
for n=1:300

line([0,x(n),d(n)],[0,y(n),e]);
line([d(n)-1,d(n)+1,d(n)+1,d(n)-1,d(n)-1],[e-3,e-3,e+3,e+3,e-3]);
ground(0,0,3,0)
anchor(-3,0,0,0)
pause(0.01);
axis ([-100 100 -100 100]);
axis equal;
clf;

end

th=linspace(th2,180-th1,300)
[d,th3]=slider_solve(th,R,L,e,-1)

x=R*cosd(th),
y=R*sind(th)
for n=1:300

line([0,x(n),d(n)],[0,y(n),e]);
line([d(n)-1,d(n)+1,d(n)+1,d(n)-1,d(n)-1],[e-3,e-3,e+3,e+3,e-3]);
ground(0,0,3,0)
anchor(-3,0,0,0)
pause(0.01);
axis ([-100 100 -100 100]);
axis equal;
clf;

end

因為滑塊驅動會滑到第二象限,所以mode輸入包括1和-1。
所以角度要從th2跑到180-th1,其他的跟前面一樣


輸入slider (26,31,10)可得曲桿驅動的情形


而輸入slider2(26,31,10)可得到滑塊驅動的情形

3 則留言:

大鳥 提到...

許惠善有在論壇交放動畫的方法,可以參考看看喔!!這樣你的部落格會更漂亮!!!

tenMB 提到...

哇謝謝大鳥

Terence 提到...

這一題可以參考黃君席寫的.
他分析的超清楚超good~~~
加油!!!
放動畫真的會讓你的作業更有feeling呦~~

(路過的小豪......XD)