huright 发表于 2007-5-24 21:29

单叶双曲面(C语言)

单叶双曲面(C语言)源代码

#include <graphics.h>
#include <math.h>
#include <stdio.h>
#define pi 3.1415926
void main()
{
int graphdrive=DETECT,graphmode;
int X,Y,x,y,i;
float angle1,angle2,R1,R2,R,H;
printf("Please input the radius of the ceil circle=R1(0~160):\n");
scanf("%f",&R1);
printf("Please input the radius of the bottom circle=R2(0~160):\n");
scanf("%f",&R2);
printf("Please input the radius of tht throat circle=R:\n");
scanf("%f",&R);
if(R>R1||R>R2)
{
printf("Yous input is ERROR!\n");
return;
}
printf("Please the height of the bin-surface=H:\n");
scanf("%f",&H);
initgraph(&graphdrive,&graphmode,"");
angle2=acos(R/R1)+acos(R/R2);
cleardevice();
setbkcolor(9);
setcolor(15);
setlinestyle(CENTER_LINE,2,NORM_WIDTH);
line(160,25,160,500);
line(25,400,300,400);
setcolor(4);
setlinestyle(SOLID_LINE,0,THICK_WIDTH);
line(160-R1,280,160+R1,280);
line(160-R2,280-H,160+R2,280-H);
circle(160,400,R1);
circle(160,400,R2);
circle(160,400,R);
setcolor(2);
setlinestyle(SOLID_LINE,0,NORM_WIDTH);
i=1;
do{
angle1=pi/18*i;
x=160+(R1*cos(angle1));
X=160+(R2*cos(angle1+angle2));
y=400+(R1*sin(angle1));
Y=400+(R2*sin(angle1+angle2));
line(x,y,X,Y);
line(x,280,X,280-H);
i++;
}
while(i<=36);
getch();
closegraph();
}
页: [1]
查看完整版本: 单叶双曲面(C语言)