2/11/07

第八章 瞬時中心

瞬時中心之軌跡


物件運動過程中,常會在特定時間環繞一定點轉動,此定點稱為瞬時中心。瞬時中心有固定者、有活動者。以四連桿為例,除四個端點為瞬心外,其餘有兩瞬心屬活動性的。一在兩固定瞬心之連線上,另一則會隨四連桿之位置而變化。

在求順心之位置時,必須利用兩點連線之沿線。因此需按其位置比例求出其座標。本例中,以Xsect函數求瞬心座標。其輸入需要第一線上a1、a2與第二線上b1、b2的座標。這四點座標均以複數表示。所得之交點所得之交點P也是採用複數座標。

整個函數名稱為movef4centros,其輸入項與f4bar函數相同。程式內容如下:

四連桿程式內容



function movef4centros(r,th1,td2,tdd2,sigma,driver,ntimes,npts)
%
%function movef4centros(r,th1,td2,tdd2,sigma,driver,ntimes,npts)
%Author: D. S. Fon, BIME, NTU. Date: Feb. 17, 2007
%draw the centros of four-bar links
%Inputs:
% r: row vector for four links
% th1: frame angle
% th2: crank angle or couple angle
% td2,tdd2:angular velocity and acceleration of the driving link.
% sigma: assembly mode
% driver: 0 for crank, 1 for coupler
% ntimes: no. of cycles
% npts: number of points divided
%example:
% movef4centros([4 2 3 4],0,10,0,-1,0,4,100)
%
clf;
if nargin<10, ntimes=3;npts=100;end;
figure(1);
[Qstart, Qstop]=fb_angle_limits(r,th1,driver);
npoint=abs(npts);
th2=linspace(Qstart,Qstop,npoint);
val=zeros(6,npoint);
for i=1:npoint,
[vr b]=f4bar(r,th1,th2(i),td2,tdd2,sigma,driver);
[pa1,f1]=Xsect(0,vr(1,6),vr(1,1),vr(2,6));
[pa2,f2]=Xsect(0,vr(1,1),vr(1,6),vr(2,6));
val(1:3,i)=[vr(1,1);vr(2,1);vr(1,1)+vr(4,1)];
val(4:5,i)=[pa2;pa1];
end
x=real(val);y=imag(val);
h=f4limits(r,th1,sigma,driver);
line(x(5,:)',y(5,:)','color','r','linestyle','-');
line(x(4,:)',y(4,:)','color','b','linestyle','-.');
range=([1.5*min(min(x(1:3,:))) 2*max(max(x(1:3,:))),...
1.5*min(min(y(1:3,:))) 2*max(max(y(1:3,:)))]);
axis(range);axis equal;grid off;
for i=2:4,set(h(i),'erasemode','xor','linewidth',6);end
h0=line('xdata',[],'ydata',[],'erasemode','xor','color','k',...
'marker','o','linestyle',':');
i=0;s=-1;axis off;
title('Hit enter to continue...');
for m=1:ntimes
s=-s;
if abs(Qstop-Qstart-360)<1,i=0;s=1;end;
while 1,
i=i+s;
if i>npoint|i==0,break;end;
set(h(2),'xdata',[0 x(2,i)], 'ydata',[0 y(2,i)]);%crank
set(h(3),'xdata',[x(2,i) x(3,i)], 'ydata',[y(2,i) y(3,i)]);%coupler
set(h(4),'xdata',[x(1,i) x(3,i)], 'ydata',[y(1,i) y(3,i)]);%Rocker
set(h0,'xdata',[0 x(5,i) x(3,i) x(4,i) x(1,i)],...
'ydata',[0 y(5,i) y(3,i) y(4,i) y(1,i)]);
drawnow; %flush the draw buffer
pause;
end
end % for m loop

function [P,ff]=Xsect(a1,a2,b1,b2)
a1x=real(a1);a1y=imag(a1);a2x=real(a2);a2y=imag(a2);
b1x=real(b1);b1y=imag(b1);b2x=real(b2);b2y=imag(b2);
A=[(a2y-a1y) -(a2x-a1x); (b2y-b1y) -(b2x-b1x)];
determinant=abs(det(A));
if determinant > 10^(-10) %if matrix is not singular
B=[(a2y-a1y)*a1x-(a2x-a1x)*a1y;...
(b2y-b1y)*b1x-(b2x-b1x)*b1y];
s=A\B; P=complex(s(1),s(2));ff=0;
else % Locate the intersection when the matrix is singular
xx= 10^10;
angle = atan2((a2y-a1y),(a2x-a1x));
P=complex(xx,xx*tan(angle));ff=1;
end



執行例


>> movef4centros([4 2 3 4],0,10,0,-1,0,4,100)
Qstart =
3.6e-006
Qstop =
360