多功能冲击钻价格:光栅的模拟的C程序代码

来源:百度文库 编辑:高校问答 时间:2024/05/08 10:47:12
计算物理上的光栅模拟

这个以前做过
#include <graphics.h>
#include <dos.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>
void main()
{
float a=0.4,d=0.8;
int n=4;
int graphdrv = DETECT, graphmode, errorcode;
int left=0,right=120;
float b,c,r,pi=3.141593,k,i,f;
r=right/n/n;
k=2*pi/1e7;
d=d/1000;
a=a/1000;
initgraph(&graphdrv,&graphmode,"F:\\borlandc\\BGI");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}

line(320,0,320,479);
line(0,240,639,240);
delay(2000);
for(f=1;f<320;f++)
{
delay(50);
b=pi*a*sin(f/1e5)/k;
c=pi*d*sin(f/1e5)/k;
i=2*r*pow(sin(b)/b*sin(n*c)/sin(c),2);
line(320-left,240-right,320-f,240-i);
line(320+left,240-right,320+f,240-i);
left=f;
right=i;
}
while(!kbhit());
closegraph();
}