38 using namespace swarm;
44 const double mass_planet = 0.0001;
48 const double xpos[4] = { -2.0, +2.0, -4.0, +4.0 };
58 double norm(
double x,
double y){
64 int main(
int argc,
char* argv[]){
66 cout <<
"Usage: parabolic_collision <outputfilename>" << endl;
68 const string outputfn = argv[1];
72 for(
int i = 0; i < nsys ; i++){
73 ensemble::SystemRef s = ens[i];
80 s[0][0].pos() = 0, s[0][1].pos() = 0, s[0][2].pos() = 0 ;
81 s[0][0].vel() = 0, s[0][1].vel() = 0, s[0][2].vel() = 0 ;
85 for(
int b = 1; b < nbod; b++){
86 s[b].mass() = mass_planet;
88 double x =
xpos[b-1], y = x*x/4/
R -
R ;
89 double vmag = sqrt(2*
mu/norm(x,y)) ;
90 double vdirx = (x/abs(x))/norm(1,x/2/R), vdiry = abs(x)/2/R / norm(1,x/2/R);
93 s[b][0].pos() =
x , s[b][0].vel() = -vmag*vdirx ;
94 s[b][1].pos() = y , s[b][1].vel() = -vmag*vdiry ;
95 s[b][2].pos() = 0 , s[b][2].vel() = 0 ;