2007年4月12日 星期四

作業五

5.1.1



%設上手臂長30cm
L1=30
%用line將每一點連起來
arm1x=[0 (-4)*sind(30) (-4)*sind(45) (-4)*sind(60) -4 -5 -5*cosd(30) -5*cosd(45) -5*cosd(60) 0 5*cosd(60) 5*cosd(45) 5*cosd(30) 5 4 4*cosd(30) 4*cosd(45) 4*cosd(60) 0]
arm1y=-L1+[ -4 -4*cosd(30) -4*cosd(45) -4*cosd(60) 0 L1 5*sind(30)+L1 5*sind(45)+L1 5*sind(60)+L1 L1+5 5*sind(60)+L1 5*sind(45)+L1 5*sind(30)+L1 L1 0 -4*sind(30) -4*sind(45) -4*sind(60) -4]
line(arm1x,arm1y);
axis equal

%設下手臂長25
L2=25
arm2x=[ -4 4*cosd(150) 4*cosd(135) 4*cosd(120) 0 L2 L2+3*cosd(60) L2+3*cosd(45) L2+3*cosd(30) L2+3 L2+3*cosd(30) L2+3*cosd(45) L2+3*cosd(60) L2 0 (-4)*sind(30) (-4)*sind(45) (-4)*sind(60) -4]
arm2y=-L1+[ 0 4*sind(150) 4*sind(135) 4*sind(120) 4 3 3*sind(60) 3*sind(45) 3*sind(30) 0 -3*sind(30) -3*sind(45) -3*sind(60) -3 -4 -4*cosd(30) -4*cosd(45) -4*cosd(60) 0]
line(arm2x,arm2y);
axis equal

%設手掌8cm
L3=8
palmx=L2+[ -3 3*cosd(150) 3*cosd(135) 3*cosd(120) 0 L3 L3+5*cosd(60) L3+5*cosd(45) L3+5*cosd(30) L3+5 L3+5*cosd(30) L3+5*cosd(45) L3+5*cosd(60) L3 0 (-3)*sind(30) (-3)*sind(45) (-3)*sind(60) -3]
palmy=-L1+[ 0 3*sind(150) 3*sind(135) 3*sind(120) 3 5 5*sind(60) 5*sind(45) 5*sind(30) 0 -5*sind(30) -5*sind(45) -5*sind(60) -5 -3 -3*cosd(30) -3*cosd(45) -3*cosd(60) 0]
line(palmx,palmy);
axis equal


5.1.2


%設計一個function輸入L1L2L3 和旋轉角度
function body(L1,L2,L3,theta1,theta2,theta3)
arm1x=[0 (-4)*sind(30) (-4)*sind(45) (-4)*sind(60) -4 -5 -5*cosd(30) -5*cosd(45) -5*cosd(60) 0 5*cosd(60) 5*cosd(45) 5*cosd(30) 5 4 4*cosd(30) 4*cosd(45) 4*cosd(60) 0]
arm1y=-L1+[ -4 -4*cosd(30) -4*cosd(45) -4*cosd(60) 0 L1 5*sind(30)+L1 5*sind(45)+L1 5*sind(60)+L1 L1+5 5*sind(60)+L1 5*sind(45)+L1 5*sind(30)+L1 L1 0 -4*sind(30) -4*sind(45) -4*sind(60) -4]
line(arm1x,arm1y);
axis equal

arm2x=[ -4 4*cosd(150) 4*cosd(135) 4*cosd(120) 0 L2 L2+3*cosd(60) L2+3*cosd(45) L2+3*cosd(30) L2+3 L2+3*cosd(30) L2+3*cosd(45) L2+3*cosd(60) L2 0 (-4)*sind(30) (-4)*sind(45) (-4)*sind(60) -4]
arm2y=[ 0 4*sind(150) 4*sind(135) 4*sind(120) 4 3 3*sind(60) 3*sind(45) 3*sind(30) 0 -3*sind(30) -3*sind(45) -3*sind(60) -3 -4 -4*cosd(30) -4*cosd(45) -4*cosd(60) 0]
line(arm2x,arm2y);
axis equal

palmx=[ -3 3*cosd(150) 3*cosd(135) 3*cosd(120) 0 L3 L3+5*cosd(60) L3+5*cosd(45) L3+5*cosd(30) L3+5 L3+5*cosd(30) L3+5*cosd(45) L3+5*cosd(60) L3 0 (-3)*sind(30) (-3)*sind(45) (-3)*sind(60) -3]
palmy=[ 0 3*sind(150) 3*sind(135) 3*sind(120) 3 5 5*sind(60) 5*sind(45) 5*sind(30) 0 -5*sind(30) -5*sind(45) -5*sind(60) -5 -3 -3*cosd(30) -3*cosd(45) -3*cosd(60) 0]
line(palmx,palmy);
axis equal
clf

axis equal
%將座標調到適當範圍
AXIS([-70 70 -70 40]);
x1=arm1x*cosd(90-theta1)-arm1y*sind(90-theta1);
y1=arm1x*sind(90-theta1)+arm1y*cosd(90-theta1);
line(x1,y1)
theta2=180-(theta2-theta1);
x2=arm2x*cosd(-theta2)-arm2y*sind(-theta2)-L1*sind(theta1-90);
y2=arm2x*sind(-theta2)+arm2y*cosd(-theta2)-L1*cosd(theta1-90);
line(x2,y2)
theta3=theta3-theta2-180
x3=palmx*cosd(theta3)-palmy*sind(theta3) -L1*sind(theta1-90)+L2*cosd(theta2);
y3=palmx*sind(theta3)+palmy*cosd(theta3) -L1*cosd(theta1-90)-L2*sind(theta2);
line(x3,y3)

5.1.3




%在視窗中輸入(30cm,25cm,8cm,120度, 120度, 120度)
body(30,25,8,120,120,120)


5.1.4
http://www.youtube.com/watch?v=8CUKsS9slEQ

L1=30
L2=25
L3=8
arm1x=[0 (-4)*sind(30) (-4)*sind(45) (-4)*sind(60) -4 -5 -5*cosd(30) -5*cosd(45) -5*cosd(60) 0 5*cosd(60) 5*cosd(45) 5*cosd(30) 5 4 4*cosd(30) 4*cosd(45) 4*cosd(60) 0]
arm1y=-L1+[ -4 -4*cosd(30) -4*cosd(45) -4*cosd(60) 0 L1 5*sind(30)+L1 5*sind(45)+L1 5*sind(60)+L1 L1+5 5*sind(60)+L1 5*sind(45)+L1 5*sind(30)+L1 L1 0 -4*sind(30) -4*sind(45) -4*sind(60) -4]
line(arm1x,arm1y);
axis equal

arm2x=[ -4 4*cosd(150) 4*cosd(135) 4*cosd(120) 0 L2 L2+3*cosd(60) L2+3*cosd(45) L2+3*cosd(30) L2+3 L2+3*cosd(30) L2+3*cosd(45) L2+3*cosd(60) L2 0 (-4)*sind(30) (-4)*sind(45) (-4)*sind(60) -4]
arm2y=[ 0 4*sind(150) 4*sind(135) 4*sind(120) 4 3 3*sind(60) 3*sind(45) 3*sind(30) 0 -3*sind(30) -3*sind(45) -3*sind(60) -3 -4 -4*cosd(30) -4*cosd(45) -4*cosd(60) 0]
line(arm2x,arm2y);
axis equal

palmx=[ -3 3*cosd(150) 3*cosd(135) 3*cosd(120) 0 L3 L3+5*cosd(60) L3+5*cosd(45) L3+5*cosd(30) L3+5 L3+5*cosd(30) L3+5*cosd(45) L3+5*cosd(60) L3 0 (-3)*sind(30) (-3)*sind(45) (-3)*sind(60) -3]
palmy=[ 0 3*sind(150) 3*sind(135) 3*sind(120) 3 5 5*sind(60) 5*sind(45) 5*sind(30) 0 -5*sind(30) -5*sind(45) -5*sind(60) -5 -3 -3*cosd(30) -3*cosd(45) -3*cosd(60) 0]
line(palmx,palmy);
axis equal
clf

%角度從下列度數範圍每10度增加
theta1=linspace(-90,-75,10)
theta2=linspace(-45,-35,10)
theta3=linspace(-30,-10,10)
axis equal

% n跑十次
for n=1:10;
AXIS([-10 40 -20 40]);
axis equal
x1=arm1x*cosd(90-theta1(n))-arm1y*sind(90-theta1(n));
y1=arm1x*sind(90-theta1(n))+arm1y*cosd(90-theta1(n));
line(x1,y1)
theta2(n)=180-(theta2(n)-theta1(n));
x2=arm2x*cosd(-theta2(n))-arm2y*sind(-theta2(n))-L1*sind(theta1(n)-90);
y2=arm2x*sind(-theta2(n))+arm2y*cosd(-theta2(n))-L1*cosd(theta1(n)-90);
line(x2,y2)
theta3(n)=theta3(n)-theta2(n)-180
x3=palmx*cosd(theta3(n))-palmy*sind(theta3(n)) -L1*sind(theta1(n)-90)+L2*cosd(theta2(n));
y3=palmx*sind(theta3(n))+palmy*cosd(theta3(n)) -L1*cosd(theta1(n)-90)-L2*sind(theta2(n));
line(x3,y3)
axis equal
pause(0.5)
clf
end


5.2.1





%以連桿畫出手指的形狀
L1=10
L2=8
L3=7


linkshape([0,0],[-L1,0])
linkshape([-L1,0],[-L1-L2,0])
linkshape([-L1-L2,0],[-L1-L2-L3,0])


5.2.2

http://www.youtube.com/watch?v=A6O1RhBqZCA
%做一個funtion輸入手掌的尺寸
%假設四隻手指在同一個水平上
%輸入每隻手指的尺寸
function finger(palm)
%食指
%輸入每節和手掌的關係式
L1=palm/3.5
L2=palm/3-1
L3=palm/3-2
linkshape([0,0],[-L1,0])
linkshape([-L1,0],[-L1-L2,0])
linkshape([-L1-L2,0],[-L1-L2-L3,0])
%設每個關節從零度跑到90度每次跑8度
theta1=linspace(0,90,8)
theta2=linspace(0,90,8)
theta3=linspace(0,90,8)
for n=1:8
axis equal
AXIS([-5 30 -10 20]);

x1=-L1*cosd(theta1(n))
y1=L1*sind(theta1(n))
linkshape([0,0],[x1,y1])
theta2(n)=theta1(n)+theta2(n)
x2=x1-L2*cosd(theta2(n))
y2=y1+L2*sind(theta2(n))
linkshape([x1,y1],[x2,y2])
theta3(n)=theta2(n)+theta3(n)
x3=x2-L3*cosd(theta3(n))
y3=y2+L3*sind(theta3(n))
linkshape([x2,y2],[x3,y3])
axis equal
pause(0.3)
clf
end


%中指
L1=palm/3
L2=palm/3-1
L3=palm/3-2
linkshape([0,0],[-L1,0])
linkshape([-L1,0],[-L1-L2,0])
linkshape([-L1-L2,0],[-L1-L2-L3,0])

theta1=linspace(0,90,8)
theta2=linspace(0,90,8)
theta3=linspace(0,90,8)
for n=1:8
axis equal
AXIS([-5 30 -10 20]);

x1=-L1*cosd(theta1(n))
y1=L1*sind(theta1(n))
linkshape([0,0],[x1,y1])
theta2(n)=theta1(n)+theta2(n)
x2=x1-L2*cosd(theta2(n))
y2=y1+L2*sind(theta2(n))

linkshape([x1,y1],[x2,y2])

theta3(n)=theta2(n)+theta3(n)
x3=x2-L3*cosd(theta3(n))
y3=y2+L3*sind(theta3(n))
linkshape([x2,y2],[x3,y3])
axis equal
pause(0.3)
clf
end
%無名指
L1=palm/3.5
L2=palm/3.5
L3=palm/3.5
linkshape([0,0],[-L1,0])
linkshape([-L1,0],[-L1-L2,0])
linkshape([-L1-L2,0],[-L1-L2-L3,0])

theta1=linspace(0,90,8)
theta2=linspace(0,90,8)
theta3=linspace(0,90,8)
for n=1:8
axis equal
AXIS([-5 30 -10 20]);

x1=-L1*cosd(theta1(n))
y1=L1*sind(theta1(n))
linkshape([0,0],[x1,y1])
theta2(n)=theta1(n)+theta2(n)
x2=x1-L2*cosd(theta2(n))
y2=y1+L2*sind(theta2(n))

linkshape([x1,y1],[x2,y2])

theta3(n)=theta2(n)+theta3(n)
x3=x2-L3*cosd(theta3(n))
y3=y2+L3*sind(theta3(n))
linkshape([x2,y2],[x3,y3])
axis equal
pause(0.3)
clf
end
%小指

L1=palm/4
L2=palm/4
L3=palm/4
linkshape([0,0],[-L1,0])
linkshape([-L1,0],[-L1-L2,0])
linkshape([-L1-L2,0],[-L1-L2-L3,0])

theta1=linspace(0,90,8)
theta2=linspace(0,90,8)
theta3=linspace(0,90,8)
for n=1:8
axis equal
AXIS([-5 30 -10 20]);

x1=-L1*cosd(theta1(n))
y1=L1*sind(theta1(n))
linkshape([0,0],[x1,y1])
theta2(n)=theta1(n)+theta2(n)
x2=x1-L2*cosd(theta2(n))
y2=y1+L2*sind(theta2(n))

linkshape([x1,y1],[x2,y2])

theta3(n)=theta2(n)+theta3(n)
x3=x2-L3*cosd(theta3(n))
y3=y2+L3*sind(theta3(n))
linkshape([x2,y2],[x3,y3])
axis equal
pause(0.3)
clf
end

5.2.3
假設我們知道每隊的手指長L1,L2,L3
知道角加速度a1,a2,a3
那麼切線加速度即為a*L
法線加速度為w*w*L
藉由此關係式可以求出來切線法線加速度

沒有留言: