1 // -*- compile-command:"g++ -lX11 -Wall -g -O3 -o mash misc.o universe.o polygon.o mash.cc -L/usr/X11R6/lib/"; -*-
17 int main(int argc, char **argv) {
19 int w = 1000, h = 1000;
20 Universe universe(nb_heur + 1, w, h);
24 scalar_t xs[nb], ys[nb];
25 for(int k = 0; k < nb; k++) {
26 scalar_t alpha, radius;
28 alpha = - (M_PI / scalar_t(nb/2)) * k;
31 alpha = - (M_PI / scalar_t(nb/2)) * (nb - k - 1);
34 xs[k] = scalar_t(w)/2 + radius * cos(-alpha);
35 ys[k] = scalar_t(h)/2 + radius * sin(-alpha);
38 p = new Polygon(1.0, 0.5, 0.5, 0.5, xs, ys, nb);
39 p->set_position(scalar_t(w/2), scalar_t(h) * 0.75, 0);
40 p->set_speed(0, 0, 0);
41 universe.initialize(p);
42 universe.add_polygon(p);
45 scalar_t xs[] = { -30, 30, 30, -30 };
46 scalar_t ys[] = { -10, -10, 10, 10 };
48 Polygon *blocks[nb_heur];
50 for(int h = 0; h < nb_heur; h++) {
51 blocks[h] = new Polygon(1.0, 1.0, 1.0, 0.0, xs, ys, 4);
53 blocks[h]->set_position(drand48() * w, drand48() * h/10, M_PI * drand48());
54 blocks[h]->set_speed(0, 0, 0);
55 } while(universe.collide(blocks[h]));
56 universe.initialize(blocks[h]);
57 universe.add_polygon(blocks[h]);
62 for(int n = 0; n < 1000; n++) {
63 for(int h = 0; h < nb_heur; h++) {
64 blocks[h]->apply_force(dt, blocks[h]->_center_x, blocks[h]->_center_y, 0, 10);
69 ofstream os("/tmp/mash.fig");
70 universe.print_fig(os);