2007年5月11日 星期五

第五次作業

b94611013 林詠舜作業

1.假設上、下手臂,以及手掌之外觀都接近橢圓形。
function arm(A,B,d)
if nargin==2,d=4;
end;d=abs(d);
AB=(B(1)+j*B(2))-(A(1)+j*A(2));
D=abs(AB);
th=angle(AB);
t=linspace(pi/2,2.5*pi,50);
Cout=max(d/2,1)*exp(j*t');
%利用複數平面畫出橢圓
if d>0
Z=[Cout(1:25);D+Cout(26:50);D+Cout(50);Cout(1)];
else
Z=[0;D];
end;
xx=real(Z);
yy=imag(Z);
x=xx*cos(th)-yy*sin(th)+A(1);
y=xx*sin(th)+yy*cos(th)+A(2);
line(x,y);
axis equal;

2.%依照輸入的個人手臂資料,畫出其狀態圖,若輸入資料有誤(如關節可動的角度,手臂的長度)時,會告知其錯誤。

function body(L1,L2,L3,theta1,theta2,theta3)
if theta1 < -90 theta2 >110;
input('theta1 must be in the [-90 110]');
elseif theta2 > 0 theta2 < -180; input('theta2 must be in the [-180 0]'); elseif theta3 > 10 theta3 < -30; input('theta3 must be in the [-30 10]'); elseaxis([-5 30 -25 10]); C = [cosd(-theta1) -sind(-theta1);sind(-theta1) cosd(-theta1)]; c = C*[L1;0]; B = [cosd(theta1+theta2) -sind(theta1+theta2);sind(theta1+theta2) cosd(theta1+theta2)]; b = c + B*[L2;0]; A = [cosd(theta1+theta2+theta3) -sind(theta1+theta2+theta3);sind(theta1+theta2+theta3) cosd(theta1+theta2-theta3)]; a = b + A*[L3;0]; arm(a',b',5); arm(b',c',4.7); arm(c',[0 0],5); axis equal;end; 3.body(20,25,10,90,-45,-30)的位置關係圖

4.程式碼
axis([-5 30 -25 10]);
mov = avifile('arm.avi','fps',2);
for n = 0:10;
clf;
body(20,25,10,90-1.5*n,-45+n,-30+2*n);
pause(0.5);
F = getframe(gca);
mov = addframe(mov,F);
end;
mov = close(mov);

模擬動畫

作業二

1.就人的手指頭關節而言,可以將其解析成為下列之三連桿。其中,手指與手掌之間的接頭是球對,手指的各關節的接頭則是旋轉對。每一關節所旋轉的角度是有所限制的,從0度到90度,在本題中,我所用的速度是相對速度(以手掌與手指之間的接點為基準點),並假設在運動中,各關節不會速度過快而脫臼,且限制指關節的轉動方向皆在同一平面上。

2.用來描繪手指之鍵結的程式,並依照個人的可動範圍作為調整

function finger(L1,L2,L3,theta1,theta2,theta3,O)
% L1 = 手指的末節,L2 = 手指的中間,L3 = 手指的前端% theta1.2.3為之間的角度,O = 手指與手掌連接的座標
if theata1 > 90 theta1 < -20; input('theta1 must be in the [-20 90]'); elseif theta2 > 95 theta2 < -5; input('theta2 must be in the [-5 95]'); elseif theta3 > 95 theta3 < -5; input('theta3 must be in the [-5 95]'); else; axis([-4 8 -4 8]); C = [cosd(90-theta1) -sind(90-theta1);sind(90-theta1) cosd(90-theta1)]; c = C*[L1;0] + O' ; B = [cosd(90-theta1-theta2) -sind(90-theta1-theta2);sind(90-theta1-theta2) cosd(90-theta1-theta2)]; b = c + B*[L2;0]; A = [cosd(90-theta1-theta2-theta3) -sind(90-theta1-theta2-theta3);sind(90-theta1-theta2-theta3) cosd(90-theta1-theta2-theta3)]; a = b + A*[L3;0]; linkshape(a',b',0.5); linkshape(b',c',0.5); linkshape(c',O,0.5); grid on; axis equal; end 依照以上程式,我的手指向後彎的極限位置是finger(3,2,2,-20,-5,-5),如圖一而手指向前曲的極限位置是finger(3,2,2,90,95,95),如圖二

3.投出球的時候,手指各關節間的角加速度以為40*/180 rad,其姿勢如下圖,是在finger_analsis(3,2,2,70,10,10,[0 0],40,40,40)下作分析分析圖 分析的程式如下:

function finger_analsis(L1,L2,L3,theta1,theta2,theta3,O,fa1,fa2,fa3)
% L1 = 手指的末節,L2 = 手指的中間,L3 = 手指的前端% theta1.2.3為之間的角度,O = 手指與手掌連接的座標 即旋轉座標之中心% fa1.2.3為手指之間的角加速度
if theata1 <> 90 theta1 < -20; input('theta1 must be in the [-20 90]'); elseif theta2 > 95 theta2 < -5; input('theta2 must be in the [-5 95]'); elseif theta3 > 95 theta3 < -5; input('theta3 must be in the [-5 95]'); elseif fa1 > 90 fa1 <> 90 fa2 <> 90 fa3 < 0;
input('fa1 must be in the [0 90]');
elsev1 = L1*fa1*pi/180;
%各關節間的切線加速度
v2 = L2*fa2*pi/180;
v3 = L3*fa3*pi/180;
a1 = v1*v1/L1;
%各關節的向心加速度
a2 = v2*v2/L2;
a3 = v3*v3/L3;
C = [cosd(90-theta1) -sind(90-theta1);sind(90-theta1) cosd(90-theta1)];
c = C*[L1;0] + O';
%關節位置
x = C*[L1;-v1] + O';
%關節之切線加速度
l = C*[L1-a1;0] + O';
%關節之向心加速度
s = C*[L1-a1;-v1] + O';
%關節的合力加速度
B = [cosd(90-theta1-theta2) -sind(90-theta1-theta2);sind(90-theta1-theta2) cosd(90-theta1-theta2)];
b = c + B*[L2;0];
y = c + B*[L2;-v2];
m = c + B*[L2-a2;0];
t = c + B*[L2-a2;-v2];
A = [cosd(90-theta1-theta2-theta3) -sind(90-theta1-theta2-theta3);sind(90-theta1-theta2-theta3) cosd(90-theta1-theta2-theta3)];
a = b + A*[L3;0];
z = b + A*[L3;-v3];
n = b + A*[L3-a3;0];
u = b + A*[L3-a3;-v3];
linkshape(a',b',0.5);
%畫出手指各關節之相關圖
linkshape(b',c',0.5);
linkshape(c',O,0.5);
line([c(1) x(1)],[c(2) x(2)],'Color','r');
%畫出關節間的切線加速度之大小
line([b(1) y(1)],[b(2) y(2)],'Color','r');
line([a(1) z(1)],[a(2) z(2)],'Color','r');
line([c(1) l(1)],[c(2) l(2)],'Color','g');
%畫出關節間的向心加速度之大小
line([b(1) m(1)],[b(2) m(2)],'Color','g');
line([a(1) n(1)],[a(2) n(2)],'Color','g');
line([c(1) s(1)],[c(2) s(2)],'Color','k');
%畫出關節間的向心加速度之大小
line([b(1) t(1)],[b(2) t(2)],'Color','k');
line([a(1) u(1)],[a(2) u(2)],'Color','k');
grid on;
axis equal;
end

沒有留言: