2 ////////////////////////////////////////////////////////////////////
5 // Written by Francois Fleuret //
6 // Contact <francois.fleuret@idiap.ch> for comments & bug reports //
9 ////////////////////////////////////////////////////////////////////
11 #include "vision_problem_10.h"
14 VisionProblem_10::VisionProblem_10() { }
16 void VisionProblem_10::generate(int label, Vignette *vignette) {
18 int xs[nb_shapes], ys[nb_shapes];
24 scalar_t alpha = drand48() * 2 * M_PI;
25 scalar_t radius = drand48() * Vignette::width / 2;
26 scalar_t xc = drand48() * Vignette::width;
27 scalar_t yc = drand48() * Vignette::height;
28 for(int n = 0; n < nb_shapes; n++) {
29 xs[n] = int(xc + part_size/2 +
30 radius * sin(alpha + n * 2 * M_PI / scalar_t(nb_shapes)));
31 ys[n] = int(yc + part_size/2 +
32 radius * cos(alpha + n * 2 * M_PI / scalar_t(nb_shapes)));
35 for(int n = 0; n < nb_shapes; n++) {
36 xs[n] = int(drand48() * Vignette::width);
37 ys[n] = int(drand48() * Vignette::height);
40 } while(cluttered_shapes(part_size, nb_shapes, xs, ys));
46 for(int n = 0; n < nb_shapes; n++) {
48 shape.randomize(part_size / 2, part_hole_size / 2);
50 error |= shape.overwrites(vignette, xs[n], ys[n]);
51 shape.draw(vignette, xs[n], ys[n]);