X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=flatland.git;a=blobdiff_plain;f=polygon.cc;h=ba629c5734bd12b7b622c3f954fe67060dda21a0;hp=b64fbe4ab3d570038ff491f82e823f315aedc05a;hb=c1f1040936d977cd2b3a276c725e223198377d2a;hpb=2cd32038873961c8ff3861efb218fad75fbcbf69 diff --git a/polygon.cc b/polygon.cc index b64fbe4..ba629c5 100644 --- a/polygon.cc +++ b/polygon.cc @@ -1,26 +1,26 @@ /* - * dyncnn is a deep-learning algorithm for the prediction of - * interacting object dynamics - * - * Copyright (c) 2016 Idiap Research Institute, http://www.idiap.ch/ - * Written by Francois Fleuret - * - * This file is part of dyncnn. - * - * dyncnn is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as - * published by the Free Software Foundation. - * - * dyncnn is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with dyncnn. If not, see . - * - */ + + flatland is a simple 2d physical simulator + + Copyright (c) 2016 Idiap Research Institute, http://www.idiap.ch/ + Written by Francois Fleuret + + This file is part of flatland + + flatland is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License version 3 as + published by the Free Software Foundation. + + flatland is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with flatland. If not, see . + +*/ #include @@ -517,6 +517,14 @@ void Polygon::apply_collision_forces(scalar_t dt, int n_polygon, Polygon *p) { } +bool Polygon::collide_with_borders(scalar_t xmin, scalar_t ymin, + scalar_t xmax, scalar_t ymax) { + for(int n = 0; n < _nb_vertices; n++) { + if(_x[n] <= xmin || _x[n] >= xmax || _y[n] <= ymin || _y[n] >= ymax) return true; + } + return false; +} + bool Polygon::collide(Polygon *p) { for(int n = 0; n < _nb_vertices; n++) { int np = (n+1)%_nb_vertices;