From: Francois Fleuret Date: Fri, 16 Sep 2016 19:49:37 +0000 (+0200) Subject: Update. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=6fccc7a7c7b24476bafed5449150600a37c49b14;p=universe.git Update. --- diff --git a/generate.cc b/generate.cc index 73da00d..f851694 100644 --- a/generate.cc +++ b/generate.cc @@ -18,6 +18,7 @@ #include #include #include +#include using namespace std; @@ -39,10 +40,13 @@ void generate_png(Universe *universe, scalar_t scale, FILE *file) { } 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; @@ -67,7 +71,7 @@ int main(int argc, char **argv) { 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(); @@ -75,33 +79,31 @@ int main(int argc, char **argv) { 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; @@ -133,7 +135,13 @@ int main(int argc, char **argv) { { 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); @@ -157,7 +165,6 @@ int main(int argc, char **argv) { 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); @@ -183,17 +190,17 @@ int main(int argc, char **argv) { { 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); } }