int main(int argc, char* argv[]){ vector x; // Eulerian angles x=(alpha, beta ,gamma) vector w; // 回転系角速度 vector rL; // 回転系角運動量 double t,h; int nsteps, print_interval; std::ifstream fin(infile, std::ios::in); if (!fin.is_open()) error(argv[0], infile , ":Cannot open file for reading"); // 回転軸の天頂角の初期値p(degree), 回転軸の方位角の初期値q(degree), 回転周期の初期値 T(second) // 天頂角の初期値のずれu(degree) fin >> nsteps >> print_interval >> T >> p >> q >> u; // ........ Initialization .............................. initial_condition(x,w); h = T/200.0; cout.precision(16); std::ofstream fout(outfile, std::ios::out); if(!fout.is_open()) error(argv[0], outfile , ":Cannot open file for writing"); fout.precision(16); fout.setf(std::ios_base::fixed, std::ios_base::floatfield); // graphics double told=0.0,yold=0.0; char *devname="?"; if (argc == 2) devname = argv[1]; if (cpgopen(devname) != 1) // open a graphics device exit(1); // change the size of the view surface cpgpap(6.0,1); // set window and viewpoint and draw labeled frame double tmin=0.0,tmax=20.0,ymin=0.0,ymax=16000.0; cpgenv(tmin,tmax,ymin,ymax,0,0); cpglab("t(sec)","Lx(angular momentum)"," ");// write labels x-axis,y-axis and top of plot for(int i=0; i < nsteps; i++){ t= h*(i+1) rk4(x,w,dxdt,h); w=omega(x); // w の再計算 rL= A*L; double E=(I[0]*w[0]*w[0]+I[1]*w[1]*w[1]+I[2]*w[2]*w[2])/2.0; // 回転エネルギー if (((i+1) % print_interval ) == 0){ //fout << t << " " << rL[0] << " " << rL[1]<< " " << rL[2] << " " << //E << " " << cos(x[1]) << "\n"; cpgsci(2); // set color index cpgmove(told,yold); // move pen // draw a line from the current position to a point cpgdraw(t,rL[0]); told=t; yold=rL[0]; } } cpgclos(); close a selected graphics device return 0; }