#include <stdint.h>
#include <errno.h>
#include <string.h>
+#include <sys/stat.h>
using namespace std;
}
int main(int argc, char **argv) {
- scalar_t world_width = 400;
- scalar_t world_height = 400;
- scalar_t grab_start_x = world_width * 0.5;
- scalar_t grab_start_y = world_height * 0.75;
+ const scalar_t world_width = 400;
+ const scalar_t world_height = 400;
+ const scalar_t grab_start_x = world_width * 0.5;
+ const scalar_t grab_start_y = world_height * 0.75;
+ const int nb_blocks = 1;
+ const scalar_t block_size = 80;
+ const int nb_iterations = 250;
Universe *universe;
Polygon *grabbed_polygon;
universe = new Universe(10, world_width, world_height);
for(int n = 0; n < nb_pairs; n++) {
- cout << "Example " << n << endl;
+ if(n%1000 == 0) { cout << "Example #" << n+1 << endl; }
do {
universe->clear();
const int nb_attempts_max = 100;
int nb_attempts = 0;
- for(int u = 0; u < 10; u++) {
+ for(int u = 0; u < nb_blocks; u++) {
Polygon *pol = 0;
nb_attempts = 0;
do {
- scalar_t square_size = 80;
-
scalar_t x[] = {
- - square_size * 0.5,
- + square_size * 0.5,
- + square_size * 0.5,
- - square_size * 0.5,
+ - block_size * 0.5,
+ + block_size * 0.5,
+ + block_size * 0.5,
+ - block_size * 0.5,
};
scalar_t y[] = {
- - square_size * 0.5,
- - square_size * 0.5,
- + square_size * 0.5,
- + square_size * 0.5,
+ - block_size * 0.5,
+ - block_size * 0.5,
+ + block_size * 0.5,
+ + block_size * 0.5,
};
- scalar_t delta = square_size / sqrt(2.0);
+ scalar_t delta = block_size / sqrt(2.0);
scalar_t object_center_x = delta + (world_width - 2 * delta) * drand48();
scalar_t object_center_y = delta + (world_height - 2 * delta) * drand48();
scalar_t red, green, blue;
- red = 0.90;
+ red = 1.00;
green = red;
blue = red;
delete pol;
{
char buffer[1024];
- sprintf(buffer, "%s/dyn_%06d_world_0.png", dir, n);
+ sprintf(buffer, "%s/%03d/", dir, n/1000);
+ mkdir(buffer, 0777);
+ }
+
+ {
+ char buffer[1024];
+ sprintf(buffer, "%s/%03d/dyn_%06d_world_0.png", dir, n/1000, n);
FILE *file = fopen(buffer, "w");
generate_png(universe, scaling, file);
fclose(file);
grab_trace.draw_polygon(1, n, xp, yp);
}
- const int nb_iterations = 250;
scalar_t dt = 0.1;
for(int i = 0; i < nb_iterations; i++) {
scalar_t xf = grabbed_polygon->absolute_x(grab_relative_x, grab_relative_y);
{
char buffer[1024];
- sprintf(buffer, "%s/dyn_%06d_world_1.png", dir, n);
+ sprintf(buffer, "%s/%03d/dyn_%06d_grab.png", dir, n/1000, n);
FILE *file = fopen(buffer, "w");
- generate_png(universe, scaling, file);
+ grab_trace.write_png(file);
fclose(file);
}
{
char buffer[1024];
- sprintf(buffer, "%s/dyn_%06d_grab.png", dir, n);
+ sprintf(buffer, "%s/%03d/dyn_%06d_world_1.png", dir, n/1000, n);
FILE *file = fopen(buffer, "w");
- grab_trace.write_png(file);
+ generate_png(universe, scaling, file);
fclose(file);
}
}