2007年6月13日 星期三

動畫已上傳

之前因為未搞清楚動畫如何上傳

所以各作業的動畫皆未附上

現已補上

在各作業處

歡迎指教

2007年6月12日 星期二

第十三次作業

第一題

試設計一組複式齒輪,使其轉速比為125(請說明思考步驟及結果)。

ans:

因為轉速比最好是在10以下,所以我先將125開根號

(125)^1/2=11.18 → 超過10,所以我將125取其平方根

(125)^1/3=5 → 在十以內,因此我取其為轉速比

若最小齒輪取齒數=10;

所以我可以取齒數序分別為10:50; 10:50; 10:50

構成一組複式齒輪組

因為開立方出來的值為整數,所以理論上沒有誤差值




第二題

請指出本學期中你自己最感得意的一次作業(請說明其原因,且該作業必須在自己的部落格內)

ans:
這一學期下來,最令我滿意的ㄧ次作業是第十二次

並不是因為所花的時間最多(第五次作業花的時間最多,從早上八點到晚上十二點,扣掉吃飯與休息時間,約花了十二小時)

主要是因為這次作業的最後一題

製作此題的動畫,雖然可運用老師已做好的move2_gear.m 直接輸入參數即得動畫

不過若是運用draw_gear.m的程式來修改的話,

則必須花上ㄧ些工夫

而我就是採用後者

晚上在總圖地下自習室花了不少時間

尤其是要將兩個齒輪對上的部分

更是讓我傷透腦筋

雖然最後發現其實很簡單

有點惱自己為什麼這麼不聰明

不過最後看到齒輪在自己眼前順暢的轉動還是很有成就感

2007年6月6日 星期三

第十二次作業

我是劉昶志

我5/31有來上課

第一題

一組標準全齒輪齒輪之徑節為8(亦可使用自設值),齒數分別為30T與48T,其工作壓力角為20度(可為14.5或25度,自選)。
試求其接觸線長度,與接觸比。

由老師所製作的程式contact_ratio

代入

徑節=8

齒輪齒數為30及48

工作壓力角為20度

由matlab執行程式後可得以下資料
[c_ratio, c_length,ad,pc,pb,r2,r3,ag]=contact_ratio(8,30,48,20)

c_ratio =

1.7005


c_length =

0.6275


ad =

0.1250


pc =

0.3927


pb =

0.3690


r2 =

3.7500


r3 =

6


ag =

10.4850 9.9211 20.4061
6.5532 6.2007 12.7538

其中

接觸比=1.7005
接觸長度= 0.6275 吋

又改代入

徑節=8

齒輪齒數為30及48

工作壓力角為25度

由matlab執行程式後可得以下資料
>> [c_ratio, c_length,ad,pc,pb,r2,r3,ag]=contact_ratio(4,30,48,25)

c_ratio =

1.5028


c_length =

1.0697


ad =

0.2500


pc =

0.7854


pb =

0.7118


r2 =

7.5000


r3 =

12


ag =

9.1921 8.8419 18.0340
5.7450 5.5262 11.2712


其中

接觸比= 1.5028
接觸長度=1.0697吋

第二題

兩齒輪之節圓、基圓直徑各為如何?請列式計算其結果。

第一齒輪節圓直徑為 30/8 = 3.75

第二齒輪節圓直徑為 48/8= 6

第一齒輪基圓直徑為3.75 * cos (20) = 3.523

第二齒輪基圓直徑為6 * cos(20) = 5.638吋



第三題

此組齒輪是否會產生干涉現象?試列式證明之。


(N2^2+2*N2*N3)sin^2(壓力角) > = 4

(N3^2+2*N3*N2)sin^2(壓力角) > = 4(1+N2)

代入數值

442.18 > 176

606.41 > 124

所以整個接合的過程皆不會有干涉發生


第四題

可否利用draw_gear.m繪出其接合情形,並繪出其動畫效果。

將draw_gear.m的程式稍作修改

加入第二齒輪的齒數參數 N2 ,以及旋轉角度參數 n

function [coords]=draw_gear(Dp,N,N2,phi,range,x0,y0,n)
% [coords]=draw_gear(Dp,N,phi,range,x0,y0)
% To draw a whole gear
% Inputs:
% Dp: Diametrical pitch
% N: no of teeth in a gear
% N2: no of teeth in second gear
% phi: pressure angle, degrees
% range: the section range to be drawn
% x0,y0: the location of the gear center
% Example [coords]=draw_gear(10,15,20,360,0,0)
% rotate direction

[coord,theta,rp,rb]=tooth(Dp,N,phi);
coords=[];i=0;
while i < range
coord1=rotate2D(coord,-i-n*theta/3,x0,y0);
coords=[coords;coord1];
i=i+theta;
end
plot(coords(:,1),coords(:,2));hold on;
[coord]=bushing(rp/8,x0,y0);
plot(coord(:,1),coord(:,2),'b-');
[coord]=bushing(-rp,x0,y0);
plot(coord(:,1),coord(:,2),'r:');
[coord]=bushing(-rb,x0,y0);
plot(coord(:,1),coord(:,2),'b:');

%下面為第二齒輪的部份

[coord,theta,rp2,rb]=tooth(Dp,N2,phi);
coords=[];i=0;
while i < range
coord1=rotate2D(coord,-i+n*theta/3+180+theta/2,x0+rp+rp2,y0);

%“-i+n*theta/3+180+theta/2”是為了使齒輪卡緊

coords=[coords;coord1];
i=i+theta;
end
plot(coords(:,1),coords(:,2));hold on;
[coord]=bushing(rp2/8,x0+rp+rp2,y0);
plot(coord(:,1),coord(:,2),'b-');
[coord]=bushing(-rp2,x0+rp+rp2,y0);
plot(coord(:,1),coord(:,2),'r:');
[coord]=bushing(-rb,x0+rp+rp2,y0);
plot(coord(:,1),coord(:,2),'b:');

再寫出主程式

for m=1:360;

clf

[coords1]=draw_gear2(8,30,48,20,360,1,0,m)

pause(0.02)

end

可做出以下動畫

2007年5月30日 星期三

第十一次作業 第三題

第三題

你能讓此凸輪迴轉嗎?

ans:
可以,只要將function pincam稍作修改

以下是可轉動的function pincam5,由正上方固定的紅色桿

可清晰看出在凸輪旋轉時,桿位置的變化


function [x,y]=pincam5(cth,r0,s,e,L,range,pattern,cw)
%Find the pin type cam with an offsect e
%Inputs:
% cth:angle of cam, degrees
% r0:radius of base circle
% e:offset
% s:stroke
% L:length of pin
% cw:rotation direction of cam(-counterclockwise,+clockwise
%pattern = denote the type of motion used(a 3 element-row matrix)
% 1:uniform 2:parabolic 3:simple harmonic 4: cycloidal
% 5:polynomial motion
% example [4 3]
%range =the degrees the specific motion starts, eg.[90 180 240]
% Example: [x y]=pincam([10 60],5,2,1,10,[90 180 240],[4 3],-1)
figure(1);
n=0;
for mm=1:10:360;
n=n+1;
m=mm*pi/180;
clf;
th=cth*pi/180;
s0=sqrt(r0*r0-e*e);
for i=1:length(cth)
t=th(i)*cw;
A=[cos(t-m) -sin(t-m);sin(t-m) cos(t-m)];
[ym,yy,yyy]=dwell(cth(i),range,pattern);
x0=s0+ym*s;
Sx=[0 x0 x0+L;e e e];
X=A\Sx;
x(i)=X(1,2);y(i)=X(2,2);
%line(X(1,1:2),X(2,1:2));
%line(X(1,2:3),X(2,2:3),'linewidth',3,'color','red')
end
[yw,yyw,yyyw]=dwell(cth,range,pattern)
y1=yw*s+r0;
y2=yw*s+r0+L;
line([0 0],[y1(n) y2(n)],'linewidth',3,'color','red')
hold on;
plot([0 x],[0 y],'ro',x,y,'k-')
axis ([-50 50 -50 50])
pause(0.05)
end

所繪出的動畫如下

第十ㄧ次作業 第二題

第二題

設凸輪之半徑為15公分,以順時針方向旋轉,其從動件為梢型,垂直接觸,長為10公分
從動件之運動係依照第二項之運動型式。試繪出此凸輪之工作曲線。

ans:
由function pincam可得此題運動圖形

1.假設衝程為20

pincam(1:10:360,15,20,0,10,[100 200 260],[2 1],-1)


2.假設衝程為20,偏致量為5

pincam(1:10:360,15,20,5,10,[100 200 260],[2 1],-1)

第十ㄧ次作業 第一題

第ㄧ題

某凸輪開始時先在0-100°區間滯留,然後提升後在200至260°區間滯留,其高度(衝程)為5公分,
其餘l由260°至360°則為返程。升程採用等加速度運動,返程之運動型式自定。設刻度區間為10°,
試繪出其高度、速度及加速度與凸輪迴轉角度間之關係。

ans:

依照function plot_Dwell,再帶入本題題目所給的條件,由於反成的運動型是自由,
所以我們可得以下五個運動關係圖

1.返程為等速度運動

plot_dwell(0:10:360,5,[2 1],[100 200 260])



2.返程為拋物線運動〈等加速度運動〉

plot_dwell(0:10:360,5,[2 2],[100 200 260])



3.返程為簡諧運動

plot_dwell(0:10:360,5,[2 3],[100 200 260])



4.返程為擺線運動

plot_dwell(0:10:360,5,[2 4],[100 200 260])



5.返程為多項式運動

plot_dwell(0:10:360,5,[2 5],[100 200 260])

2007年5月22日 星期二

第十次作業第一題


由運動學的定理可知

若將整個運動平面視為一負數平面

則P點的速度=iωX*exp(iωt+iθ)

P點的加速度=-ω*ω*Xexp(iωt+iθ)


若使M有ㄧ速度V及一加速度a

則在t秒時,

P點的速度=v+at+iωX*exp(iωt+iθ)

P點的加速度=a-ω*ω*Xexp(iωt+iθ)


以上面的結論推論四連桿的運動情形

因為一號桿的運動速度為零

所以M點的速度也為零

若以二號桿驅動

則二號桿的兩端P Q兩點相對於M的運動關係

應與上面的結論同

2007年5月16日 星期三

以第三桿角度改變的連續圖

以第二桿角度改變的連續圖

第九次作業--滑塊驅動範圍圖

第九次作業--第三桿驅動範圍圖

第九次作業

學號:b9461005

R=10+05=15
L=15+5=20


當以第二桿驅動時,發現四種情況皆無法成立
因此無法移動



當以第三桿驅動時,符合第一類情形
0≦r4,且0≦r2-r4≦r3
所以帶入程式中
drawsldlimits([1 15 20 10],0,-1,1)

Qstart =

-14.4775


Qstop =

194.4775
得出角度的範圍在 -14.4775 < θ < 194.4775



當以滑塊為驅動時,發現符合第二類的情形
|r2-r3|< r4
由程式跑出r1的範圍在 -33.54 < r1 < 33.54,
可知,滑塊的移動範圍在 -33.54 ─ 33.54之間

drawsldlimits([1 15 20 10],0,-1,2)

Qstart =

-33.5410


Qstop =

33.5410

又由公式
θmin =θ1 + sin-1((r2+r3) / r4),
θmax =θ1 +π- sin-1((r2+r3) / r4)

在這範圍間第二桿角度的變化為
θmin =-0.06
θmax =3.20

又利用程式
for n=1:10:360
drawsldlinks([1 15 20 10],0,n,1,0)
pause(0.02)
end

以及
for n=1:10:360
drawsldlinks([1 15 20 10],0,n,1,1)
pause(0.02)
end

可觀察出若以第一桿或以第二桿驅動時的連續變化

2007年5月9日 星期三

8.4圖

8.3圖

8.2圖

第八次作業

8.1
[val,form]=f4bar([4 3 3 5],0,45,10,0,-1,0);
abs(val(:,3))'

ans =

0 10.0000 16.2681 4.9677
abs(val(:,4))'

ans =

0 0 491.4428 383.6120



8.2
drawlinks([4 3 3 5],0,45,10,0,-1,0);
hold on
line([2.1 2.1+0.41],[2.1 2.1-2.45],'color','red');
line([2.1+1.1 2.1+1.1-2.1],[2.1+2.8 2.1+2.8-2.1],'color','red');
line([2.1 2.1-18.7],[2.1 2.1-4.39]);

8.3
[Ang1, Ang2]=fb_angle_limits([4 3 3 5],0,0)

Ang1 =

28.9550


Ang2 =

331.0450

drawlinks([4 3 3 5],0,28.995,0,0,-1,0)

drawlinks([4 3 3 5],0, 331,0,0,-1,0)

8.4
for n=0:18;
drawlinks([4 3 3 5],0,n*20,0,0,-1,0);
hold on
end

8.5
axis equal
for n=1:43;
drawlinks([4 3 3 5],0,n*7,0,0,-1,0);
hold on
pause(0.002)
end

2007年4月25日 星期三

第七次作業動畫

動畫

第七次作業


7.1 7.2
ground(0,0,6,0)
anchor(-3,0,0,0)
for t=1:1:5
dyad_rrrr([15 20 10],[0 0 0],[0.2,0.3,0.4],[0,0.1,0.2],t)
end


7.3
for t=1:0.5:5;
clf;
ground(0,0,6,0);
anchor(-3,0,0,0);
dyad_rrrr ([15 20 10],[0 0 0],[0.2,0.3,0.4],[0,0.1,0.2],t);
pause(0.1);
end;


我將老師的FUNCTION增加了角位移的移動
function dyad_rrrr(rho,theta,td,tdd,t)

% Call function dyad(rho,theta,td,tdd) to
% analyze a dyad linkage composing cranks and a dyad with drawing.
% Inputs: rho:length of links
% theta:incling angles, deg.
% td:angular velocity, rad/s
% tdd:angular acceleration, rad/s^2
% Example:
% dyad_draw([15 10 5],[0 60 90],[.5 .8 .5],0)
w=theta+td*t+tdd*t^2/2
td2=td+t*tdd
[vec,data] = dyad(rho,w,td2,tdd);
x=[0;cumsum(real(data(:,1)))];y=[0;cumsum(imag(data(:,1)))];
for i=1:length(x)-1
linkshape([x(i) y(i)],[x(i+1) y(i+1)],1);
axis equal;
end
for i=1:length(x)-1
linkshape([x(i) y(i)],[x(i+1) y(i+1)],1);
end
for i=1:length(x)-1
linkshape([x(i) y(i)],[x(i+1) y(i+1)],1);
axis equal;
end
for k=1:length(rho)
x0=x(k+1);y0=y(k+1);
vx=x0+real(data(k,2));vy=y0+imag(data(k,2));
ax=x0+real(data(k,3));ay=y0+imag(data(k,3));
line([x0 vx],[y0 vy],'marker','s','linewidth',2);
line([x0 ax],[y0 ay],'marker','s','color','r','linewidth',3)
end
sdata=sum(data);
ss=[real(sdata(1)) imag(sdata(1))];
vv=[real(sdata(2)) imag(sdata(2))];
aa=[real(sdata(3)) imag(sdata(3))];
line([0 ss(1)],[0 ss(2)],'linestyle',':','linewidth',2)
line([ss(1) ss(1)+vv(1)],[ss(2) ss(2)+vv(2)],...
'marker','d','color','g','linewidth',3)
line([ss(1) ss(1)+aa(1)],[ss(2) ss(2)+aa(2)],...
'marker','d','color','m','linewidth',3)
axis equal;grid on

第六次作業

6.1.1
 共有12桿及15個結,其中C.D.E.F.I這五個結要算兩個,因為是三桿相接
6.1.2
 M=3*(N-J-1)+F
 N=12 J=15 
 F=12*1+1*1+2*2=17
 M=-12+17=5 DOF=5
6.1.3
 函式輸入為
  gruebler(12,[12 1 2])
 得DOF=5;
6.1.4
 滑塊與地面之間是可移動的狀態,所以有兩個自由度,是一個滑動結,
滑槽因可滑動與轉動,所以有兩個自由度

6.2.1
 A.B.D為球結,DOF=3
 C為圓柱結,DOF=2
F.E為旋轉結,DOF=1
6.2.2
 m=6(N-J-1)+F=6(6-6-1)+13
 m=7 DOF=7
6.2.3
 函式輸入為
 gruebler(6,[2 0 0 3 1])
 得DOF=7
6.2.4
 A.B結點間與C.D結點之間的桿,因為可自由自轉,所以有兩個惰性自由度,所以其可動度要減二,m=7-2=5; 

6.3.1
 在一四連桿組中,最短桿與最長桿之和小於其他兩桿之和時,則至少有一桿為可旋轉桿。稱為葛拉索型;
 而,其他類型則總稱非葛拉索型。
6.3.2
 
〈一〉7+4=6+5→中立連桿組
 
MATLAB計算如下
>>grashof(1,[7 4 6 5])
ans =
Neutral Linkage
〈二〉8+3.6>5.1+4.1→非葛拉索連桿
MATLAB計算如下
>>grashof(1,[8 3.6 5.1 4.1])
ans =
Non-Grashof Linkage

〈三〉6.6+3.1<5.4+4.7→葛拉索第一類桿
 因為接地桿鄰近最短桿,所以曲柄搖桿型
MATLAB計算如下
>>grashof(1,[5.4 3.1 6.6 4.7])
ans =
Crank-Rocker Linkage

6.3.3
 觀察以上三組數據,只有第二組四連桿為非葛拉索型,若要將其改成葛拉索型機構,如果將最長桿或最短桿減短,或者把第二和第三長的連桿長度增長,就是為了要達成葛拉索機構最長與最短之和小於另外兩桿之和。

第六次作業第一題圖


第六次作業第二題


2007年4月11日 星期三

第五次作業

5.1L1=20;L2=15;L3=7;theta1=0;theta2=180;theta3=270;L=L3+5;cir1=0:540;cir2=180:270;cir3=270:360;cir4=0:360;cir5=0:90;cir6=90:180;axis equal;%arm(L1);x1=2*cosd(cir1);y1=2*sind(cir1);
x2=5*cosd(cir2);y2=5*sind(cir2);
x3=5*cosd(cir3)+L1;y3=5*sind(cir3);
x4=2*cosd(cir4)+L1;y4=2*sind(cir4);
x5=5*cosd(cir5)+L1;y5=5*sind(cir5);
x6=5*cosd(cir6);y6=5*sind(cir6);
m=(L1)/2*tand(10);xa=L1/2;ya=-m-5;
xb=L1/2;yb=m+5;
finalx1=[x1 x2 xa x3 x4 x5 xb x6];
finaly1=[y1 y2 ya y3 y4 y5 yb y6];
rox1=finalx1*cosd(-theta1)-finaly1*sind(-theta1);roy1=finalx1*sind(-theta1)+finaly1*cosd(-theta1);arm1=line(rox1,roy1);
%arm2;xm1=2*cosd(cir1);ym1=2*sind(cir1);
xm2=5*cosd(cir2);ym2=5*sind(cir2);
xm3=3*cosd(cir3)+L2;ym3=3*sind(cir3);
xm4=2*cosd(cir4)+L2;ym4=2*sind(cir4);
xm5=3*cosd(cir5)+L2;ym5=3*sind(cir5);
xm6=5*cosd(cir6);ym6=5*sind(cir6);
mm=L2/2*tand(10);xma=L2/2;yma=-mm-5;
xmb=L2/2;ymb=mm+5;
finalx2=[xm1 xm2 xma xm3 xm4 xm5 xmb xm6];finaly2=[ym1 ym2 yma ym3 ym4 ym5 ymb ym6];rox2=finalx2*cosd(180-theta1+theta2)-finaly2*sind(180-theta1+theta2);roy2=finalx2*sind(180-theta1+theta2)+finaly2*cosd(180-theta1+theta2);a1=L1*cosd(-theta1)-0*sind(-theta1);b1=L1*sind(-theta1)+0*cosd(-theta1);
hx2=rox2+a1;hy2=roy2+b1;
arm2=line(hx2,hy2);
%palm;L=L3+4;xn1=2*cosd(cir1);yn1=2*sind(cir1);
xn3=2*cosd(cir5);yn3=2*sind(cir5);
xfinger=[-4 -2 -2 -0.5 0 0.5 2 2 3];yfinger=[-4*L/7 -3*L/7 -6*L/7 -4*L/7 -L -4*L/7 -6*L/7 -4*L/7 -5*L/7];
finalx3=[xn1 xfinger xn3];finaly3=[yn1 yfinger yn3];rox3=finalx3*cosd(360-theta1+theta2+theta3)-finaly3*sind(360-theta1+theta2+theta3);roy3=finalx3*sind(360-theta1+theta2+theta3)+finaly3*cosd(360-theta1+theta2+theta3);a2=L2*cosd(180-theta1+theta2)-0*sind(180-theta1+theta2);b2=L2*sind(180-theta1+theta2)+0*cosd(180-theta1+theta2);
hx3=rox3+a1+a2;hy3=roy3+b1+b2;palm=line(hx3,hy3);

5.2function bady(L1,L2,L3,theta1,theta2,theta3)
axis equal;L=L3+5;cir1=0:540;cir2=180:270;cir3=270:360;cir4=0:360;cir5=0:90;cir6=90:180;%arm(L1);x1=2*cosd(cir1);y1=2*sind(cir1);
x2=5*cosd(cir2);y2=5*sind(cir2);
x3=5*cosd(cir3)+L1;y3=5*sind(cir3);
x4=2*cosd(cir4)+L1;y4=2*sind(cir4);
x5=5*cosd(cir5)+L1;y5=5*sind(cir5);
x6=5*cosd(cir6);y6=5*sind(cir6);
m=(L1)/2*tand(10);xa=L1/2;ya=-m-5;
xb=L1/2;yb=m+5;
finalx1=[x1 x2 xa x3 x4 x5 xb x6];
finaly1=[y1 y2 ya y3 y4 y5 yb y6];
rox1=finalx1*cosd(-theta1)-finaly1*sind(-theta1);roy1=finalx1*sind(-theta1)+finaly1*cosd(-theta1);line(rox1,roy1);
%arm2(L2);
xm1=2*cosd(cir1);ym1=2*sind(cir1);
xm2=5*cosd(cir2);ym2=5*sind(cir2);
xm3=3*cosd(cir3)+L2;ym3=3*sind(cir3);
xm4=2*cosd(cir4)+L2;ym4=2*sind(cir4);
xm5=3*cosd(cir5)+L2;ym5=3*sind(cir5);
xm6=5*cosd(cir6);ym6=5*sind(cir6);
mm=L2/2*tand(10);xma=L2/2;yma=-mm-5;
xmb=L2/2;ymb=mm+5;
finalx2=[xm1 xm2 xma xm3 xm4 xm5 xmb xm6];finaly2=[ym1 ym2 yma ym3 ym4 ym5 ymb ym6];rox2=finalx2*cosd(180-theta1+theta2)-finaly2*sind(180-theta1+theta2);roy2=finalx2*sind(180-theta1+theta2)+finaly2*cosd(180-theta1+theta2);a1=L1*cosd(-theta1)-0*sind(-theta1);b1=L1*sind(-theta1)+0*cosd(-theta1);
hx2=rox2+a1;hy2=roy2+b1;
line(hx2,hy2);
%palm(L3);
xn1=2*cosd(cir1);yn1=2*sind(cir1);

xn3=2*cosd(cir5);yn3=2*sind(cir5);
xfinger=[-4 -2 -2 -0.5 0 0.5 2 2 3];yfinger=[-4*L/7 -3*L/7 -6*L/7 -4*L/7 -L -4*L/7 -6*L/7 -4*L/7 -5*L/7];
finalx3=[xn1 xfinger xn3];finaly3=[yn1 yfinger yn3];rox3=finalx3*cosd(360-theta1+theta2+theta3)-finaly3*sind(360-theta1+theta2+theta3);roy3=finalx3*sind(360-theta1+theta2+theta3)+finaly3*cosd(360-theta1+theta2+theta3);a2=L2*cosd(180-theta1+theta2)-0*sind(180-theta1+theta2);b2=L2*sind(180-theta1+theta2)+0*cosd(180-theta1+theta2);
hx3=rox3+a1+a2;hy3=roy3+b1+b2;line(hx3,hy3);
5.3
bady(30,30,7,90,-45,-30 )
5.4for n=0:10; clf; bady(30,30,7,-90+1.5*n,-45+1*n,-30+2*n); pause(0.2);end
5.2.1function finger(L1,L2,L3,theta1,theta2,theta3)
axis equal;
cir1=0:540;cir2=180:270;cir3=270:360;cir4=0:360;cir5=0:90;cir6=90:180;%arm(L1);x1=2*cosd(cir1);y1=2*sind(cir1);
x2=5*cosd(cir2);y2=5*sind(cir2);
x3=5*cosd(cir3)+L1;y3=5*sind(cir3);
x4=2*cosd(cir4)+L1;y4=2*sind(cir4);
x5=5*cosd(cir5)+L1;y5=5*sind(cir5);
x6=5*cosd(cir6);y6=5*sind(cir6);
m=(L1)/2*tand(10);xa=L1/2;ya=-m-5;
xb=L1/2;yb=m+5;
finalx1=[x1 x2 xa x3 x4 x5 xb x6];
finaly1=[y1 y2 ya y3 y4 y5 yb y6];
rox1=finalx1*cosd(-theta1)-finaly1*sind(-theta1);roy1=finalx1*sind(-theta1)+finaly1*cosd(-theta1);line(rox1,roy1);
%arm2(L2);
xm1=2*cosd(cir1);ym1=2*sind(cir1);
xm2=5*cosd(cir2);ym2=5*sind(cir2);
xm3=3*cosd(cir3)+L2;ym3=3*sind(cir3);
xm4=2*cosd(cir4)+L2;ym4=2*sind(cir4);
xm5=3*cosd(cir5)+L2;ym5=3*sind(cir5);
xm6=5*cosd(cir6);ym6=5*sind(cir6);
mm=L2/2*tand(10);xma=L2/2;yma=-mm-5;
xmb=L2/2;ymb=mm+5;
finalx2=[xm1 xm2 xma xm3 xm4 xm5 xmb xm6];finaly2=[ym1 ym2 yma ym3 ym4 ym5 ymb ym6];rox2=finalx2*cosd(180-theta1+theta2)-finaly2*sind(180-theta1+theta2);roy2=finalx2*sind(180-theta1+theta2)+finaly2*cosd(180-theta1+theta2);a1=L1*cosd(-theta1)-0*sind(-theta1);b1=L1*sind(-theta1)+0*cosd(-theta1);
hx2=rox2+a1;hy2=roy2+b1;
line(hx2,hy2);
%palm(L3);
xn1=2*cosd(cir1);yn1=2*sind(cir1);
xn2=3*cosd(cir2);yn2=3*sind(cir2);
xn3=2*cosd(cir3)+L2;yn3=2*sind(cir3);
xn4=2*cosd(cir4)+L2;yn4=2*sind(cir4);
xn5=2*cosd(cir5)+L2;yn5=2*sind(cir5);
xn6=3*cosd(cir6);yn6=3*sind(cir6);
mmm=L2/2*tand(10);xna=L2/2;yna=-mmm-5;
xnb=L2/2;ynb=mmm+5;
finalx3=[xn1 xn2 xna xn3 xn4 xn5 xnb xn6];finaly3=[yn1 yn2 yna yn3 yn4 yn5 ynb yn6];rox3=finalx3*cosd(360-theta1+theta2+theta3)-finaly3*sind(360-theta1+theta2+theta3);roy3=finalx3*sind(360-theta1+theta2+theta3)+finaly3*cosd(360-theta1+theta2+theta3);a2=L2*cosd(180-theta1+theta2)-0*sind(180-theta1+theta2);b2=L2*sind(180-theta1+theta2)+0*cosd(180-theta1+theta2);
hx3=rox3+a1+a2;hy3=roy3+b1+b2;line(hx3,hy3);
主程式:finger(10,10,7,0,210,200);
5.2.2finger(10,10,7,0,180,180);finger(10,10,7,90,90,90);
5.2.3function finger2(L1,L2,L3,theta1,theta2,theta3,w1,w2,w3)
axis equal;
cir1=0:540;cir2=180:270;cir3=270:360;cir4=0:360;cir5=0:90;cir6=90:180;
%arm(L1);x1=2*cosd(cir1);y1=2*sind(cir1);
x2=5*cosd(cir2);y2=5*sind(cir2);
x3=5*cosd(cir3)+L1;y3=5*sind(cir3);
x4=2*cosd(cir4)+L1;y4=2*sind(cir4);
x5=5*cosd(cir5)+L1;y5=5*sind(cir5);
x6=5*cosd(cir6);y6=5*sind(cir6);
m=(L1)/2*tand(10);xa=L1/2;ya=-m-5;
xb=L1/2;yb=m+5;
v1=L1*w1;aa1=L1*w1*w1;finalx1=[x1 x2 xa x3 x4 x5 xb x6];
finaly1=[y1 y2 ya y3 y4 y5 yb y6];vx1=L1;vy1=0+v1;rovx1=vx1*cosd(-theta1)-vy1*sind(-theta1);rovy1=vx1*sind(-theta1)+vy1*cosd(-theta1);ax1=L1-aa1;ay1=0;roax1=ax1*cosd(-theta1)-ay1*sind(-theta1);roay1=ax1*sind(-theta1)+ay1*cosd(-theta1);rox1=finalx1*cosd(-theta1)-finaly1*sind(-theta1);roy1=finalx1*sind(-theta1)+finaly1*cosd(-theta1);a1=L1*cosd(-theta1)-0*sind(-theta1);b1=L1*sind(-theta1)+0*cosd(-theta1);
line(rox1,roy1);line([a1 rovx1],[b1 rovy1]);line([a1 roax1],[b1 roay1]);
%arm2(L2);
xm1=2*cosd(cir1);ym1=2*sind(cir1);
xm2=5*cosd(cir2);ym2=5*sind(cir2);
xm3=3*cosd(cir3)+L2;ym3=3*sind(cir3);
xm4=2*cosd(cir4)+L2;ym4=2*sind(cir4);
xm5=3*cosd(cir5)+L2;ym5=3*sind(cir5);
xm6=5*cosd(cir6);ym6=5*sind(cir6);
mm=L2/2*tand(10);xma=L2/2;yma=-mm-5;
xmb=L2/2;ymb=mm+5;
v2=L2*w2;aa2=L2*w2*w2;
vx2=L2;vy2=0+v2;rovx2=vx2*cosd(180-theta1+theta2)-vy2*sind(180-theta1+theta2);rovy2=vx2*sind(180-theta1+theta2)+vy2*cosd(180-theta1+theta2);ax2=L2-aa2;ay2=0;roax2=ax2*cosd(180-theta1+theta2)-ay2*sind(180-theta1+theta2);roay2=ax2*sind(180-theta1+theta2)+ay2*cosd(180-theta1+theta2);
finalx2=[xm1 xm2 xma xm3 xm4 xm5 xmb xm6];finaly2=[ym1 ym2 yma ym3 ym4 ym5 ymb ym6];rox2=finalx2*cosd(180-theta1+theta2)-finaly2*sind(180-theta1+theta2);roy2=finalx2*sind(180-theta1+theta2)+finaly2*cosd(180-theta1+theta2);a2=L2*cosd(180-theta1+theta2)-0*sind(180-theta1+theta2);b2=L2*sind(180-theta1+theta2)+0*cosd(180-theta1+theta2);hx2=rox2+a1;hy2=roy2+b1;
line(hx2,hy2);line([a2 rovx2],[b2 rovy2]);line([a2 roax2],[b2 roay2]);
%arm3;
xn1=2*cosd(cir1);yn1=2*sind(cir1);
xn2=3*cosd(cir2);yn2=3*sind(cir2);
xn3=2*cosd(cir3)+L2;yn3=2*sind(cir3);
xn4=2*cosd(cir4)+L2;yn4=2*sind(cir4);
xn5=2*cosd(cir5)+L2;yn5=2*sind(cir5);
xn6=3*cosd(cir6);yn6=3*sind(cir6);
mmm=L3/2*tand(10);xna=L3/2;yna=-mmm-5;
xnb=L3/2;ynb=mmm+5;
v3=L3*w3;aa3=L3*w3*w3;vx3=L3;vy3=0+v3;rovx3=vx3*cosd(360-theta1+theta2+theta3)-vy3*sind(360-theta1+theta2+theta3);rovy3=vx3*sind(360-theta1+theta2+theta3)+vy3*cosd(360-theta1+theta2+theta3);ax3=L3-aa3;ay3=0;roax3=ax3*cosd(180-theta1+theta2)-ay3*sind(180-theta1+theta2);roay3=ax3*sind(180-theta1+theta2)+ay3*cosd(180-theta1+theta2);
finalx3=[xn1 xn2 xna xn3 xn4 xn5 xnb xn6];finaly3=[yn1 yn2 yna yn3 yn4 yn5 ynb yn6];rox3=finalx3*cosd(360-theta1+theta2+theta3)-finaly3*sind(360-theta1+theta2+theta3);roy3=finalx3*sind(360-theta1+theta2+theta3)+finaly3*cosd(360-theta1+theta2+theta3);a3=L3*cosd(360-theta1+theta2+theta3)-0*sind(360-theta1+theta2+theta3);b3=L3*sind(360-theta1+theta2+theta3)+0*cosd(360-theta1+theta2+theta3);
hx3=rox3+a1+a2;hy3=roy3+b1+b2;line(hx3,hy3);line([a3 rovx3],[b3 rovy3]);line([a3 roax3],[b3 roay3]);
主程式:finger2(10,10,10,90,90,90,4,4,4);

5.2.3


5.2.2


5.2.1


5.4


5.3


5.2


5.1


2007年3月28日 星期三

第四次作業

第一題
AXIS([-50 50 -50 50]);
l=5+10;x=[0 l l/2 0];y=[0 0 l 0];
line(x,y,'color','r');
t=line(x,y,'color','r');
for n=1:360
rotate(t,[0 0 1],1,[0 0 0]);
pause(0.005);
end;
for n=1:360
rotate(t,[0 0 1],1,[l 0 0]);
pause(0.005);
end;
for n=1:360
rotate(t,[0 0 1],1,[l/2 l 0]);
pause(0.005);
end;
for n=1:360
rotate(t,[0 0 1],1,[0 0 0]);
pause(0.005);
end;

第二題
a=15;
b=0;
long=10;
for n=1:30:360;
x=long*cosd(n);
y=long*sind(n);
linkshape([x,y],[0,0],4);
line([x,a],[y,b]);
end

第三題
x1=0;
x2=3;
x3=13;
x4=10;
y1=0;
y2=4;
y3=4;
y4=0;
for n=1:30:360
linkshape([x2 y2],[x1 y1],2);
linkshape([x3 y3],[x2 y2],3);
linkshape([x4 y4],[x3 y3],1.5);
linkshape([x1 y1],[x4 y4],2);
X2=x2*cosd(n)+y2*sind(n);
Y23=-x2*sind(n)+y2*cosd(n);
X3=x3+(X2-y2);
linkshape([X2 Y23],[x1 y1],2);
linkshape([X3 Y23],[X2 Y23],3);
linkshape([x4 y4],[X3 Y23],1.5);
linkshape([x1 y1],[x4 y4],2);
end;