From 9e314265ccd6163e8a79bdbb91a8bfb46ff73bca Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Fri, 10 Jul 2009 16:27:02 +0200 Subject: [PATCH] Automatic commit --- art.cc | 18 +++++++++++------- polygon.cc | 7 ++++++- universe.cc | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/art.cc b/art.cc index 37dba17..b2e8af9 100644 --- a/art.cc +++ b/art.cc @@ -31,10 +31,11 @@ int main(int argc, char **argv) { p = new Polygon(1.0, 1.0, 1.0, 0.0, xs, ys, 4); p->set_position(30 + 60 * x, 30 + 60 * y, 0); p->set_speed(0, 0, 0); + universe.initialize(p); universe.add_polygon(p); } - const int nb_projectiles = 15; + const int nb_projectiles = 1; Polygon *projectiles[nb_projectiles]; for(int b = 0; b < nb_projectiles; b++) { @@ -53,18 +54,21 @@ int main(int argc, char **argv) { // projectiles[b]->set_position(67 + 60 * 6, -60, 0); projectiles[b]->set_speed(0, 0, 0); + universe.initialize(projectiles[b]); universe.add_polygon(projectiles[b]); } - for(int n = 0; n < 20000; n++) { + scalar_t dt = 0.01; + + for(int n = 0; n < 1000; n++) { if(n%100 == 0) cout << n << endl; - for(int b = 0; b < nb_projectiles; b++) - projectiles[b]->apply_force(0.01, p->_center_x, p->_center_y, 1, 5); -// projectiles[b]->apply_force(0.01, p->_center_x, p->_center_y, 1, 10); - universe.update(0.01); + for(int b = 0; b < nb_projectiles; b++) { + projectiles[b]->apply_force(dt, p->_center_x, p->_center_y, 1, 5); + } + universe.update(dt); } - for(int n = 0; n < 10000; n++) universe.update(0.01); + for(int n = 0; n < 10000; n++) universe.update(dt); ofstream os("/tmp/universe.fig"); universe.print_fig(os); diff --git a/polygon.cc b/polygon.cc index 6f980bd..f8189d5 100644 --- a/polygon.cc +++ b/polygon.cc @@ -48,7 +48,12 @@ Polygon *Polygon::clone() { } void Polygon::print_fig(ostream &os) { - os << "2 2 0 1 0 7 50 -1 20 0.000 0 0 -1 0 0 " << _nb_vertices + 1 << endl; + // os << "2 3 0 1 0 7 50 -1 20 0.000 0 0 -1 0 0 " << _nb_vertices + 1 << endl; + int c; + do { c = int(drand48() * 32); } while(c == 7); + os << "2 3 0 1 0 6 50 -1 20 0.000 0 0 -1 0 0 " << _nb_vertices + 1 << endl; + // os << "2 3 0 0 0 " << c << " 50 -1 20 0.000 0 0 -1 0 0 " << _nb_vertices + 1 << endl; + // os << "2 3 0 2 7 " << c << " 50 -1 20 0.000 0 0 -1 0 0 " << _nb_vertices + 1 << endl; os << " "; for(int n = 0; n < _nb_vertices; n++) os << " " << int(_x[n]*10) << " " << int(_y[n]*10); os << " " << int(_x[0]*10) << " " << int(_y[0]*10); diff --git a/universe.cc b/universe.cc index 90f93ca..d349e40 100644 --- a/universe.cc +++ b/universe.cc @@ -35,7 +35,7 @@ void Universe::add_polygon(Polygon *p) { } _polygons[_nb_polygons++] = p; } else { - cerr << "To many polygons!" << endl; + cerr << "Too many polygons!" << endl; exit(1); } } -- 2.39.5