用C语言编程求解的凸轮运动规律Word文档格式.docx
《用C语言编程求解的凸轮运动规律Word文档格式.docx》由会员分享,可在线阅读,更多相关《用C语言编程求解的凸轮运动规律Word文档格式.docx(15页珍藏版)》请在冰豆网上搜索。
![用C语言编程求解的凸轮运动规律Word文档格式.docx](https://file1.bdocx.com/fileroot1/2023-1/11/f6d2ab18-ac1f-4851-b8b0-50b2c4df8149/f6d2ab18-ac1f-4851-b8b0-50b2c4df81491.gif)
{
returnd*pi/180;
}
doublef_s0(doubler0,doublee)
returnpow(pow(r0,2)-pow(e,2),0.5);
doublef_s(doublea)
doubles;
if(a>
=0&
&
a<
=45)
s=0;
elseif(a<
=112.5)s=2*h*pow(a-45,2)/pow(135,2);
=180)s=h-2*h*pow(180-a,2)/pow(135,2);
=270)s=h;
elses=h*(4-a/90+sin(change_angel(4*a-3*360))/2/pi);
returns;
doublef_x(doubles,doubles0,doublea)
{
doublex;
x=(s0+s)*sin(change_angel(a))+e*cos(change_angel(a));
returnx;
doublef_y(doubles,doubles0,doublea)
doubley;
y=(s0+s)*cos(change_angel(a))-e*sin(change_angel(a));
returny;
doublef_s1(doublea)
doubles1;
=45)s1=0;
=112.5)s1=64*h*(change_angel(a)-(pi/4))/9/pow(pi,2);
=180)s1=64*h*(pi-change_angel(a))/9/pow(pi,2);
=270)s1=0;
elses1=h*(-2/pi+2*cos(change_angel(4*a-3*360))/pi);
returns1;
doublef_x1(doubles0,doublea,doubles,doubles1)
doublex1;
x1=(s0+s)*cos(change_angel(a))+s1*sin(change_angel(a))-e*sin(change_angel(a));
returnx1;
doublef_y1(doubles0,doublea,doubles,doubles1)
doubley1;
y1=-(s0+s)*sin(change_angel(a))+s1*cos(change_angel(a))-e*cos(change_angel(a));
returny1;
doublef_xx(doublex,doublex1,doubley1)
doublexx;
xx=x+rt*y1/pow(pow(x1,2)+pow(y1,2),0.5);
returnxx;
doublef_yy(doubley,doublex1,doubley1)
doubleyy;
yy=y-rt*x1/pow(pow(x1,2)+pow(y1,2),0.5);
returnyy;
doublef_aa(doubler0,doubles,doubles1)
{doubleaa;
aa=atan(fabs(s1/(r0+s)));
returnaa;
doublef_s2(doublea)
doubles2;
=45)
s2=0;
=112.5)s2=64*h/9/pow(pi,2);
=180)s2=-64*h/9/pow(pi,2);
=270)s2=0;
elses2=-8*h*sin(change_angel(4*a-3*360))/pi;
returns2;
doublef_x2(doubles,doubles1,doublea,doubles2,doubles0)
doublex2;
x2=s2*sin(change_angel(a))+2*s1*cos(change_angel(a))-(s0+s)*sin(change_angel(a))-e*cos(change_angel(a));
returnx2;
doublef_y2(doubles,doubles1,doublea,doubles2,doubles0)
doubley2;
y2=s2*cos(change_angel(a))-2*s1*sin(change_angel(a))-(s0+s)*cos(change_angel(a))-e*cos(change_angel(a));
returny2;
doublef_p(doublex1,doubley1,doublex2,doubley2)
doublep;
p=pow(pow(x1,2)+pow(y1,2),1.5)/(x1*y2-x2*y1);
returnp;
voidmain()
doubley1,x2,r0=30,s0,a,s,s1,x1,s2,y2,x[N],y[N],xx[N],yy[N],aa,p,pa,temp_aa1=0,temp_aa2=0,temp_a1=0,temp_a2=0,temp_p=0,temp_ap=0;
s0=f_s0(r0,e);
FILE*fp=fopen("
d:
//he.txt"
"
w"
);
for(inti=0;
i<
N;
i++)
{
a=3*i;
s=f_s(a);
x[i]=f_x(s,s0,a);
y[i]=f_y(s,s0,a);
s1=f_s1(a);
x1=f_x1(s0,a,s,s1);
y1=f_y1(s0,a,s,s1);
xx[i]=f_xx(x[i],x1,y1);
yy[i]=f_yy(y[i],x1,y1);
aa=f_aa(r0,s,s1);
/*cout<
<
"
s0是:
s0<
endl;
cout<
a是:
cout<
s是:
s<
x[]是:
x[i]<
y[]是:
y[i]<
s[]是:
s1<
x1是:
x1<
y1是:
y1<
xx[]是:
xx[i]<
yy[]是:
yy[i]<
aa是:
aa<
*/
if(a>
=270&
=360)
{
if(aa>
a_max2)
{
r0+=oro;
s0=f_s0(r0,e);
i=0;
continue;
}
else
if(temp_aa2<
aa){temp_aa2=aa;
temp_a2=a;
}
=45&
=180)
a_max1)
r0+=oro;
s0=f_s0(r0+oro,e);
if(temp_aa1<
aa){temp_aa1=aa;
temp_a1=a;
}
//
s2=f_s2(a);
x2=f_x2(s,s1,a,s2,s0);
y2=f_y2(s,s1,a,s2,s0);
p=f_p(x1,y1,x2,y2);
//
if(p<
0)
{
if(fabs(p)-rt>
=p_min)
{pa=fabs(p)-rt;
if(temp_p>
pa){temp_p=pa;
temp_ap=a;
else
s0=f_s0(r0,e);
i=0;
continue;
}//endif
}//endfor
//输出
ρamin="
temp_p;
δamin="
temp_ap;
α1max="
temp_a1;
δ1max="
temp_aa1<
α2amax="
temp_a2;
δ2max="
temp_aa2;
r0="
r0;
δ="
a;
s="
fprintf(fp,"
%lf"
temp_p);
fprintf(fp,"
%c"
'
'
temp_ap);
temp_a1);
temp_aa1);
temp_a2);
temp_aa2);
r0);
a);
s);
\n'
for(i=0;
x"
="
'
;
y"
x'
y'
x[i]);
y[i]);
xx[i]);
yy[i]);
}
理论轮廓线和实际轮廓线坐标值
理论轮廓线
实际轮廓线
x
y
x
5
29.580399
3.333333
19.720266
6.541266
29.27818
4.360844
19.518787
8.064603
28.895712
5.376402
19.263808
9.565836
28.434043
6.377224
18.956029
11.040849
27.894438
7.360566
18.596292
12.4856
27.278376
8.323733
18.185584
13.896128
26.587546
9.264086
17.725031
15.268569
25.823842
10.179046
17.215895
16.599159
24.989356
11.066106
16.659571
17.884253
24.086376
11.922835
16.057584
19.120326
23.117377
12.746884
15.411585
20.303993
22.085015
13.535995
14.723343
21.432007
20.992119
14.288005
13.994746
22.501278
19.841686
15.000852
13.227791
23.508874
18.636868
15.672583
12.424578
24.452034
17.380967
16.301356
11.587311
25.348724
16.095931
17.098879
10.444378
26.220855
14.799433
17.876762
9.28798
27.071327
13.488131
18.636226
8.116997
27.902491
12.158274
19.37808
6.93004
28.71611
10.805752
20.102739
5.725414
29.513327
9.426161
20.810241
4.501093
30.294633
8.014859
21.500267
3.254697
31.059843
6.567032
22.172144
1.983495
31.808083
5.077762
22.824847
0.684418
32.537769
3.542089
23.456984
-0.645911
33.246606
1.955082
24.066781
-2.011127
33.931582
0.31191
24.652052
-3.415063
34.588975
-1.392093
25.21017
-4.86168
35.214359
-3.161354
25.738035
-6.354988
35.802621
-4.999999
26.232042
-7.898967
36.347984
-6.911778
26.688059
-9.497478
36.84403
-8.900004
27.101408
-11.154184
37.283731
-10.967487
27.466854
-12.872463
37.659491
-13.116474
27.778604
-14.655327
37.963186
-15.348585
28.030316
-16.505347
38.186209
-17.664761
28.215117
-18.424576
38.319528
-20.065212
28.325629
-20.41448
38.341105
-22.54374
28.344882
-22.268936
38.16824
-25.059319
28.227931
-23.96833
37.786351
-27.589461
27.966118
-25.701864
37.195167
-30.116639
27.555669
-27.455797
36.395804
-32.623437
26.994206
-29.216099
35.390747
-35.092657
26.280745
-30.968597
34.183826
-37.507416
25.415683
-32.699123
32.780183
-39.851248
24.400767
-34.393648
31.186232
-42.108199
23.239056
-36.038405
29.409612
-44.262921
21.934874
-37.620008
27.459135
-46.300761
20.493751
-39.125565
25.344726
-48.207843
18.922367
-40.542773
23.077359
-49.971153
17.228474
-41.860015
20.668985
-51.578608
15.42083
-43.066448
18.13246
-53.019132
13.509113
-44.152077
15.481459
-54.282713
11.503841
-45.107826
12.730398
-55.360468
9.416284
-45.925605
9.894341
-56.244689
7.258371
-46.598359
6.988908
-56.928887
5.042597
-47.120122
4.030185
-57.407836
2.781924
-47.48605
1.034621
-57.677598
0.489686
-47.692457
-1.981067
-57.73555
-1.820513
-47.736839
-4.999997
-57.580399
-4.134902
-47.617889
-8.00667
-57.239808
-6.621363
-47.336226
-10.991397
-56.742326
-9.089675
-46.924818
-13.945997
-56.089317
-11.533073
-46.384793
-16.862373
-55.282572
-13.94486
-45.717629
-19.73253
-54.3243
-16.318425
-44.925157
-22.548601
-53.21713
-18.647262
-44.009549
-25.302869
-51.964095
-20.924988
-42.973313
-27.987782
-50.56863
-23.145361
-41.81929
-30.595984
-49.03456
-25.302293
-40.550644
-33.120324
-47.36609
-27.389874
-39.170851
-35.553883
-45.567793
-29.402381
-37.683693
-37.889991
-43.644597
-31.334298
-36.093247
-40.122246
-41.601775
-33.18033
-34.403872
-42.244529
-39.444925
-34.935417
-32.620199
-44.251022
-37.17996
-36.594749
-30.747116
-46.136226
-34.813086
-38.153777
-28.789757
-47.894974
-32.350793
-39.608228
-26.753487
-49.522445
-29.799828
-40.954115
-24.643888
-51.014179
-27.167184
-42.187751
-22.466741
-52.366086
-24.460076
-43.305752
-20.228015
-53.574462
-21.685925
-44.305056
-17.933846
-54.635994
-18.852335
-45.182922
-15.59052
-55.547772
-15.967071
-45.936945
-13.204463
-56.307298
-13.038043
-46.565058
-10.782213
-56.912489
-10.073279
-47.06554
-8.330409
-57.361687
-7.080904
-47.437018
-5.855773
-57.653661
-4.069122
-47.678475
-3.365086
-57.78761
-1.046186
-47.789248
-0.865176
-57.763167
1.979618
-47.769034
1.637106
4.999995
4.134901
-57.233009
8.006312
-47.338962
6.554473
-56.688512
10.985739
-46.925061
8.823557
-55.910911
13.917739
-46.364858
10.939005
-54.870157
16.77471
-45.