模拟了各种氢原子电子云的状态,希望对大家有所帮助!!
# include "graphics.h"
# include "math.h"
# include "conio.h"
# include "stdio.h"
# define PI 3.14159
# define THETA PI/8
# define PHI PI*2/5
# define L 800
# define RR 80
# define SQR(X,Y,Z) sqrt(X*X+Y*Y+Z*Z)
int x1,y1;
float n1(x,y,z) /*1s*/
float x,y,z;
{
double r;
r=SQR(x,y,z);
return(16.0*exp(-r));
}
float n2(x,y,z) /*2s*/
float x,y,z;
{
double r;
r=SQR(x,y,z);
return(16*(2-r)*exp(-r/2));
}
float n3(x,y,z) /*2pz*/
float x,y,z;
{
double r;
r=SQR(x,y,z);
return(16*z*exp(-r/2));
}
float n4(x,y,z) /*2px*/
float x,y,z;
{
double r;
r=SQR(x,y,z);
return(20*x*exp(-r/2));
}
float n5(x,y,z) /*2py*/
float x,y,z;
{
double r;
r=SQR(x,y,z);
return(20*y*exp(-r/2));
}
float n6(x,y,z) /*3s*/
float x,y,z;
{
double r;
r=SQR(x,y,z);
return(4*(27-18*r+2*r*r)*exp(-r/3));
}
float n7(x,y,z) /*3pz*/
float x,y,z;
{
double r;
r=SQR(x,y,z);
return(4*(6-r)*z*exp(-r/3));
}
float n8(x,y,z) /*3px*/
float x,y,z;
{
double r;
r=SQR(x,y,z);
return(4.0*(6-r)*x*exp(-r/3));
}
float n9(x,y,z) /*3py*/
float x,y,z;
{
double r;
r=SQR(x,y,z);
return(8.0*(6-r)*y*exp(-r/3));
}
float n10(x,y,z) /*3dz^2*/
float x,y,z;
{
double r;
r=SQR(x,y,z);
return(6*(3*z*z-r*r)*exp(-r/3));
}
float n11(x,y,z) /*3dxz*/
float x,y,z;
{
double r;
r=SQR(x,y,z);
return(16*x*z*exp(-r/3));
}
float n12(x,y,z) /*3dyz*/
float x,y,z;
{
double r;
r=SQR(x,y,z);
return(16*y*z*exp(-r/3));
}
float n13(x,y,z) /*3dxy*/
float x,y,z;
{
double r;
r=SQR(x,y,z);
return(8*x*y*exp(-r/3));
}
float n14(x,y,z) /*3dx^2-y^2*/
float x,y,z;
{
double r;
r=SQR(x,y,z);
return(4*(x*x-y*y)*exp(-r/3));
}
static int m;
void draw(tria,x,y,z0,max,min,p)
float tria[ ],x,y,z0;
int max[ ],min[ ];
float (*p)();
{
float z,xx,yy,zz;
int nx,ny;
z=(*p)(x,y,z0);
if(z>24) z=24.0;
else if(z<-24.0) z=-24.0;
xx=-x*tria[0]+y*tria[2];
yy=-x*tria[2]*tria[3]-y*tria[0]*tria[3]+z*tria[1];
zz=-x*tria[1]*tria[2]-y*tria[1]*tria[0]-z*tria[3]+RR;
nx=L*xx/zz+320;
ny=-L*yy/zz+230;
if(ny>min[nx]&&ny<max[nx]) m=1;
else
{
if(ny<min[nx]&&ny>max[nx])
{
min[nx]=ny;max[nx]=ny;
}
else if(ny<min[nx]) {min[nx]=ny;}
else if(ny>=max[nx]){max[nx]=ny;}
if(m==1)
{
m=2;
x1=nx;
y1=ny;
}
else
{
line(x1,y1,nx,ny);
x1=nx;
y1=ny;
}
}
}
main()
{
float n1();float n2();float n3();float n4();float n5();
float n6();float n7();float n8();float n8();float n9();
float n10();float n11();float n12();float n13();float n14();
char select,answer;
int max[640],min[640];
float trif[4], x,y,z0;
static char show[10];
float (*point)();
char *p;
int gdriver=VGA,gmode=VGAHI;
initgraph(&gdriver,&gmode," ");
setviewport(15,15,635,475,1);
setbkcolor(BLACK); clearviewport();
setcolor(GREEN); p=show;
trif[0]=sin(THETA);trif[1]=sin(PHI);
trif[2]=cos(THETA);trif[3]=cos(PHI);
repeat: gotoxy(5,3);printf("1---------------1s");
gotoxy(50,3);printf("2---------------2s");
gotoxy(5,5);printf("3---------------2pz");
gotoxy(50,5);printf("4---------------2px");
gotoxy(5,7);printf("5---------------2py");
gotoxy(50,7);printf("6---------------3s");
gotoxy(5,9);printf("7---------------3pz");
gotoxy(50,9);printf("8---------------3px");
gotoxy(5,11);printf("9---------------3py");
gotoxy(50,11);printf("a---------------3dz^2");
gotoxy(5,13);printf("b---------------3dxz");
gotoxy(50,13);printf("c---------------3dyz");
gotoxy(5,15);printf("d---------------3dxy");
gotoxy(50,15);printf("e---------------3dx^2-y^2");
gotoxy(5,17);printf("0---------------Quit");
gotoxy(50,17);printf("Input your select(0-9,a-e)");
select=getch();
printf("%c",select);
x=0,y=0,z0=0;
switch(select)
{
case '1':{p="1s";point=n1;break;}
case '2':{p="2s";point=n2;break;}
case '3':{p="2pz";point=n3;z0=1;break;}
case '4':{p="2px";point=n4;break;}
case '5':{p="2py";point=n5;break;}
case '6':{p="3s";point=n6;break;}
case '7':{p="3pz";point=n7;z0=1;break;}
case '8':{p="3px";point=n8;break;}
case '9':{p="3py";point=n9;break;}
case 'a':{p="3dz^2";point=n10;z0=2.3;break;}
case 'b':{p="3dxz";point=n11;z0=1;break;}
case 'c':{p="3dyz";point=n12;z0=1;break;}
case 'd':{p="3dxy";point=n13;break;}
case 'e':{p="3dx^2-y^2";point=n14;break;}
case '0' :{ closegraph();exit();break;}
default :
{
printf("Input error!Please input gain!");
clearviewport();
goto repeat;
}
}
gotoxy(7,23);printf("Are you sure?(Y or N)\n");
answer=getch();
if(answer=='n'||answer=='N') goto repeat;
{
int i;
cleardevice();
settextstyle(DEFAULT_FONT,0,1);
outtextxy(500,430,p);
for(i=0;i<=639;i++)
{
max[i]=0;
min[i]=480;
}
x=20.0;
while(x>-20)
{
m=1;
y=-20;
i++;
while(y<=20)
{
draw(trif,x,y,z0,max,min,point);
y+=0.15;
}
x+=-0.3;
}
for(y=20.0;y>=-20.0;y+=-40.0)
{
m=1;
for(x=20.0;x>=-20.0;x-=0.1)
draw(trif,x,y,z0,max,min,point);
}
getch();
clearviewport();
}
goto repeat;
}
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |