Automatic commit
[universe.git] / universe.h
1
2 // Written and (C) by Francois Fleuret
3 // Contact <francois.fleuret@idiap.ch> for comments & bug reports
4
5 #ifndef UNIVERSE_H
6 #define UNIVERSE_H
7
8 #include <iostream>
9 #include <cmath>
10
11 using namespace std;
12
13 #include "misc.h"
14 #include "simple_window.h"
15 #include "polygon.h"
16
17 class Universe {
18   scalar_t _xmax, _ymax;
19 public:
20   int _nb_max_polygons, _nb_polygons;
21   Polygon **_polygons;
22   Universe(int nb_max_polygons, scalar_t xmax, scalar_t ymax);
23   // The destructor deletes all the added polygons
24   ~Universe();
25   void initialize(Polygon *p);
26   void clear();
27   void add_polygon(Polygon *p);
28   bool collide(Polygon *p);
29   // Compute collisions between projections of the polygons on a few
30   // axis to speed up the computation
31   void compute_pseudo_collisions(int nb_axis, int *nb_colliding_axis);
32   void apply_collision_forces(scalar_t dt);
33   bool update(scalar_t dt);
34   Polygon *pick_polygon(scalar_t x, scalar_t y);
35   void print_fig(ostream &os);
36   void draw(SimpleWindow *window);
37 };
38
39 #endif