#include<conio.h>
#include<math.h>
#include<stdio.h>
#define PI 3.1416
double a,b,c,d,e,f,g,aa,bb,cc,ccc,dd,ddd,ee,ff,gg,qi,zon,o,w,v,q,qq,
qirx,zonrx,zonrz,xierx,xierz,k,l,m,n,
P,s;
char str[9];
void func1();
void func2();
void func3();
int main()
{
printf("内球面直径:\n");
scanf("%lf",&a);
printf("球心距:\n");
scanf("%lf",&b);
printf("长度:\n");
scanf("%lf",&c);
printf("大内孔:\n");
scanf("%lf",&d);
printf("小内孔:\n");
scanf("%lf",&e);
printf("大外圆:\n");
scanf("%lf",&f);
printf("R角:\n");
scanf("%s",str);
if ( str[0] == 'J' ) {
func2();
}
else if ( str[0] == 'C' ) {
func3();
}
else {
(sscanf(str,"%lf",&g));
func1();
}
getch();
}
void func1 ()
{
dd=d+2;
cc=c+4;
ccc=c+1.1;
ee=e+0.35;
qi=b-38+48.72;
zon=b-38+20.5;
ddd=d-3;
ff=f-(g+1)*2;
o=g+1;
v=tan(PI/3.83);
w=(dd-ee)/2/v;
q=ccc-w-qi;
if(b<=56)qq=58-b;
if(b>56)qq=78-b;
printf("O6450\n");
printf("X%.1lf\n",dd);
printf("Z%.1lf\n",cc);
printf("Z%.1lf\n",ccc);
printf("W-%.2lf\n",w);
printf("Z%.2lf\n",qi);
printf("Z%.2lf\n",zon);
printf("Z%.1lf\n",cc);
printf("X%.1lf\n",ddd);
printf("Z%.1lf\n",c);
printf("X%.1lf\n",ff);
printf("X%.1lf W-%.1lf R%.1lf\n",f,o,o);
printf("过渡=%.2lf\n",q);
printf("打表垫片=%.1lf\n",qq);
}
void func2 ()
{
printf("角度:\n");
scanf("%lf",&n);
printf("倒角下方外圆:\n");
scanf("%lf",&k);
printf("R角:\n");
scanf("%lf",&l);
dd=d+2;
cc=c+4;
ccc=c+1.1;
ee=e+0.35;
qi=b-38+48.72;
zon=b-38+20.5;
ddd=d-3;
ff=f-(g+1)*2;
o=g+1;
v=tan(PI/3.83);
w=(dd-ee)/2/v;
q=ccc-w-qi;
if(b<=56)qq=58-b;
if(b>56)qq=78-b;
m=l+1.2;
qirx=k-l/tan((n+90)/2*PI/180)*2-2.4;
zonrx=k+(sin(n*PI/180))*(l/tan((n+90)/2*PI/180)*2)-(1.2-(cos(n*PI/180)*1.2))*2;
zonrz=cos(n*PI/180)*l/tan((n+90)/2*PI/180)-sin(n*PI/180)*1.2+1.2;
xierx=f;
xierz=c-((f-k)/2/tan(n*PI/180)+1.2);
printf("O6450\n");
printf("X%.1lf\n",dd);
printf("Z%.1lf\n",cc);
printf("Z%.1lf\n",ccc);
printf("W-%.2lf\n",w);
printf("Z%.2lf\n",qi);
printf("Z%.2lf\n",zon);
printf("Z%.1lf\n",cc);
printf("X%.1lf\n",ddd);
printf("Z%.1lf\n",c);
printf("x%.2lf\n",qirx);
printf("G3 x%.2lf w-%.2lf R%.2lf\n",zonrx,zonrz,m);
printf("G1 x%.2lf z%.2lf\n",xierx,xierz);
printf("过渡=%.2lf\n",q);
printf("打表垫片=%.1lf\n",qq);
}
void func3 ()
{
printf("倒角长度:\n");
scanf("%lf",&P);
printf("倒角下方外圆:\n");
scanf("%lf",&k);
printf("R角:\n");
scanf("%lf",&l);
dd=d+2;
cc=c+4;
ccc=c+1.1;
ee=e+0.35;
qi=b-38+48.72;
zon=b-38+20.5;
ddd=d-3;
ff=f-(g+1)*2;
o=g+1;
v=tan(PI/3.83);
w=(dd-ee)/2/v;
q=ccc-w-qi;
if(b<=56)qq=58-b;
if(b>56)qq=78-b;
m=l+1.2;
s=atan(((f-k)/2)/P)/PI*180;//仰望天上的光add
qirx=k-l/tan((s+90)/2*PI/180)*2-2.4;
zonrx=k+(sin(s*PI/180))*(l/tan((s+90)/2*PI/180)*2)-(1.2-(cos(s*PI/180)*1.2))*2;
zonrz=cos(s*PI/180)*l/tan((s+90)/2*PI/180)-sin(s*PI/180)*1.2+1.2;
xierx=f;
//xierz=c-((f-k)/2/tan(n*PI/180)+1.2);//仰望天上的光注释
xierz=c-((f-k)/2/tan(s*PI/180)+1.2);//仰望天上的光add
//s=tan(P/((f-k)/2))/PI*180;//仰望天上的光注释
printf("O6450\n");
printf("X%.1lf\n",dd);
printf("Z%.1lf\n",cc);
printf("Z%.1lf\n",ccc);
printf("W-%.2lf\n",w);
printf("Z%.2lf\n",qi);
printf("Z%.2lf\n",zon);
printf("Z%.1lf\n",cc);
printf("X%.1lf\n",ddd);
printf("Z%.1lf\n",c);
printf("x%.2lf\n",qirx);
printf("G3 x%.2lf w-%.2lf R%.2lf\n",zonrx,zonrz,m);
printf("G1 x%.2lf z%.2lf\n",xierx,xierz);
printf("过渡=%.2lf\n",q);
printf("打表垫片=%.1lf\n",qq);
}