新會員
Joined
: 2006/12/27 21:09 最後登入時間
: 2007/2/2 18:33
Group:
註冊會員
Level : 1 HP : 0 / 2 MP : 1 / 141 EXP : 10
|
/*position analysis of a four bar linkage*/ #include<math.h> #include<stdio.h> #define pi 3.141592654 main() { double r1,r2,r3,r4,r3p; double t2,t3,t4,dt2,dt3,dt4; double lower,upper,step,e; double e1,e2; double temp,xc,yc; nt i,flag=0; r1=6.0; r2=2.0; r3=5.0; r4=5.0; r3p=2.5; t3=70*pi/180; t4=120*pi/180; lower=0; upper=360; step=5; e=0.01*pi/180; printf("theta2 theta3 theta4 Xc Yc\n"); printf("==============================\n"); for(i=lower;i<=upper;i+=step) { flag=0; t2=i*pi/180; do { e1=r2*cos(t2)+r3*cos(t3)-r4*cos(t4)-r1; e2=r2*sin(t2)+r3*sin(t3)-r4*sin(t4); temp=r3*r4(sin(t3)*cos(t4)-cos(t3)*sin(t4)); dt3=(e1*r4*cos(t4)+e2*r4*sin(t4))/temp; dt4=(e1*r3*cos(t3)+e2*r3*sin(t3))/temp; t3+=dt3; t4+=dt4; if(fabs(dt3)<e && fabs(dt4)<e) flag=1; } while(flag==0) xc=r2*cos(t2)+r3p*cos(t3); yc=r2*sin(t2)+r3p*sin(t3); printf("%7.1f %7.3f %7.3f %7.3f %7.3f/n",t2*180/pi,t3*180/pi,t4*180/pi,xc,yc); } printf("===============================================") }
發表於: 2007/1/5 21:17
|