资源描述:
《天体运动模型程序代码》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include#include#include#include#definePI3.14159#defineMAXSTAR20000//星星总数#pragmacomment(lib,"MSIMG32.LIB")structSTAR{doublex;inty;doublestep;intcolor;};STARstar[MAXSTAR];voidInitStar(inti)//初始化星星{star[i].x=0;star[i].y=rand()%800;star[
2、i].step=((rand()%5000)/1000.0+1)*100000000;star[i].color=(int)(star[i].step*255/6.0+10);star[i].color=RGB(star[i].color,star[i].color,star[i].color);}voidMoveStar(inti){if(star[i].x>1360)InitStar(i);putpixel(pow(-1,i)*(int)star[i].x,pow(-1,i)*star[i].y,star[i].color);//画
3、新星星putpixel(pow(-1,i)*(int)star[i].x,pow(-1,i+1)*star[i].y,star[i].color);//画新星星putpixel(pow(-1,i)*(int)star[i].x+1,pow(-1,i)*star[i].y,star[i].color);//画新星星putpixel(pow(-1,i)*(int)star[i].x+1,pow(-1,i+1)*star[i].y,star[i].color);//画新星星putpixel(pow(-1,i)*(int)star[i].x,p
4、ow(-1,i)*star[i].y+1,star[i].color);//画新星星putpixel(pow(-1,i)*(int)star[i].x,pow(-1,i+1)*star[i].y+1,star[i].color);//画新星星putpixel(pow(-1,i)*(int)star[i].x-1,pow(-1,i)*star[i].y,star[i].color);//画新星星putpixel(pow(-1,i)*(int)star[i].x-1,pow(-1,i+1)*star[i].y,star[i].color);
5、//画新星星putpixel(pow(-1,i)*(int)star[i].x,pow(-1,i)*star[i].y-1,star[i].color);//画新星星putpixel(pow(-1,i)*(int)star[i].x,pow(-1,i+1)*star[i].y-1,star[i].color);//画新星星}classSolar{floata[8];//公转轨道的半长轴floate[8];//轨道的偏心率floatt[8];//公转周期floatr[8];//行星半径floatx[8];//在某处时的横坐标floaty[
6、8];//在某处时的纵坐标public:Solar(floata1[8],floate1[8],floatt1[8],floatr1[8]){for(inti=0;i<8;i++){a[i]=a1[i];e[i]=e1[i];t[i]=t1[i];r[i]=r1[i];}}voidSun(){floatm=0;m=a[0]*e[0];IMAGEimg;loadimage(&img,"E:\x\0.jpg");putimage(-m-60,-39,&img);}voidXx(){srand((unsigned)time(NULL));
7、//随机种子intN=0;floatm,n,A,C,X[2],Y[2];BeginBatchDraw();for(intc=0;c8、se7:C=A+0;break;}m=a[j]*(1-e[j]*e[j]);n=1+e[j]*cos(C);x[j]=m*cos(C)/n;y[j]=m*sin(C)/n;IMAGEimg;switch(j