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

所繪出的動畫如下

沒有留言: