Polygon *grabbed_polygon;
if(argc < 2 || argc > 3) {
- cerr << argv[0] << " <nb pairs to generate> [<seed>]" << endl;
+ cerr << argv[0] << " <nb pairs to generate> [<dir> [<seed>]]" << endl;
exit(1);
}
int nb_pairs = atoi(argv[1]);
+ char dir[1024] = "/tmp/";
+
if(argc > 2) {
+ strncpy(dir, argv[2], sizeof(dir) / sizeof(char) - 1);
+ }
+
+ if(argc > 3) {
srand48(atoi(argv[1]));
}
{
char buffer[1024];
- sprintf(buffer, "/tmp/universe_%03d_0.png", n);
+ sprintf(buffer, "%s/dyn_%06d_world_0.png", dir, n);
FILE *file = fopen(buffer, "w");
generate_png(universe, scaling, file);
+ fclose(file);
}
scalar_t grab_relative_x = grabbed_polygon->relative_x(grab_start_x, grab_start_y);
grab_trace.draw_polygon(1, n, xp, yp);
}
+ const int nb_iterations = 250;
scalar_t dt = 0.1;
- for(int i = 0; i < 500; i++) {
+ for(int i = 0; i < nb_iterations; i++) {
scalar_t xf = grabbed_polygon->absolute_x(grab_relative_x, grab_relative_y);
scalar_t yf = grabbed_polygon->absolute_y(grab_relative_x, grab_relative_y);
grabbed_polygon->apply_force(dt, xf, yf, 0.0, -1.0);
{
char buffer[1024];
- sprintf(buffer, "/tmp/universe_%03d_1.png", n);
+ sprintf(buffer, "%s/dyn_%06d_world_1.png", dir, n);
FILE *file = fopen(buffer, "w");
generate_png(universe, scaling, file);
+ fclose(file);
}
{
char buffer[1024];
- sprintf(buffer, "/tmp/grab_trace_%03d.png", n);
+ sprintf(buffer, "%s/dyn_%06d_grab.png", dir, n);
FILE *file = fopen(buffer, "w");
grab_trace.write_png(file);
+ fclose(file);
}
}