#include "nr3.h" #include "odeint.h" #include "stepper.h" #include "stepperbs.h" #include const double g = 9.813; const double C=1; // 1 N/m const double m=0.1; //0.1 kg ball const double l=2; // 2m rope // coordinates : time, x[1..3],v[1..3] struct derivatives { derivatives(){}; void operator()(const double& time, const VecDoub &coord, VecDoub &deriv) { // calculates the derivatives dydx for (int i=0; i<4; i++) deriv[i]=coord[i+3]; double r=sqrt(coord[0]*coord[0]+coord[1]*coord[1]+coord[2]*coord[2]); if (r > ode(coord,t0,20,1e-12,1e-12,stepsize,1e-8,out,d); ode.integrate(); for (int i=0; i<2000; i++) { outfil << out.xsave[i] << " "; for (int j=0; j<4; j++) outfil << out.ysave[j][i] << " "; outfil << endl; } }