--- /dev/null
+// -*- compile-command:"g++ -lX11 -Wall -g -O3 -o mash misc.o universe.o polygon.o mash.cc -L/usr/X11R6/lib/"; -*-
+
+#include <iostream>
+#include <fstream>
+#include <cmath>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <errno.h>
+#include <string.h>
+
+using namespace std;
+
+#include "misc.h"
+#include "universe.h"
+
+int main(int argc, char **argv) {
+ int nb_heur = 100;
+ int w = 1000, h = 1000;
+ Universe universe(nb_heur + 1, w, h);
+
+ {
+ int nb = 100;
+ scalar_t xs[nb], ys[nb];
+ for(int k = 0; k < nb; k++) {
+ scalar_t alpha, radius;
+ if(k < nb/2) {
+ alpha = - (M_PI / scalar_t(nb/2)) * k;
+ radius = 400;
+ } else {
+ alpha = - (M_PI / scalar_t(nb/2)) * (nb - k - 1);
+ radius = 350;
+ }
+ xs[k] = scalar_t(w)/2 + radius * cos(-alpha);
+ ys[k] = scalar_t(h)/2 + radius * sin(-alpha);
+ }
+ Polygon *p;
+ p = new Polygon(1.0, 0.5, 0.5, 0.5, xs, ys, nb);
+ p->set_position(scalar_t(w/2), scalar_t(h) * 0.75, 0);
+ p->set_speed(0, 0, 0);
+ universe.initialize(p);
+ universe.add_polygon(p);
+ }
+
+ scalar_t xs[] = { -30, 30, 30, -30 };
+ scalar_t ys[] = { -10, -10, 10, 10 };
+
+ Polygon *blocks[nb_heur];
+
+ for(int h = 0; h < nb_heur; h++) {
+ blocks[h] = new Polygon(1.0, 1.0, 1.0, 0.0, xs, ys, 4);
+ do {
+ blocks[h]->set_position(drand48() * w, drand48() * h/10, M_PI * drand48());
+ blocks[h]->set_speed(0, 0, 0);
+ } while(universe.collide(blocks[h]));
+ universe.initialize(blocks[h]);
+ universe.add_polygon(blocks[h]);
+ }
+
+ scalar_t dt = 0.01;
+
+ for(int n = 0; n < 1000; n++) {
+ for(int h = 0; h < nb_heur; h++) {
+ blocks[h]->apply_force(dt, blocks[h]->_center_x, blocks[h]->_center_y, 0, 10);
+ }
+ universe.update(dt);
+ }
+
+ ofstream os("/tmp/mash.fig");
+ universe.print_fig(os);
+ exit(0);
+}