summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/geometry/test_vector.cc
diff options
context:
space:
mode:
authorhaller2005-05-01 00:34:40 +0000
committerhaller2005-05-01 00:34:40 +0000
commit8cee2782fd70e4c19196b5fdede00ffe92808b6b (patch)
tree7e2f76ce62a420a3e054dba982d90d4d042417fc /2005/i/robert/src/geometry/test_vector.cc
parent11fbb3acd0e0c699143556e951f0e372bb1eca1b (diff)
Correction de bugs pour vector
Ajout d'un programme de test pour vector Ajout du Makefile.defs dans le répertoire geometry Ca compile mais je soupçonne des erreurs
Diffstat (limited to '2005/i/robert/src/geometry/test_vector.cc')
-rw-r--r--2005/i/robert/src/geometry/test_vector.cc136
1 files changed, 136 insertions, 0 deletions
diff --git a/2005/i/robert/src/geometry/test_vector.cc b/2005/i/robert/src/geometry/test_vector.cc
new file mode 100644
index 0000000..bc7420c
--- /dev/null
+++ b/2005/i/robert/src/geometry/test_vector.cc
@@ -0,0 +1,136 @@
+// test_vector.cc
+// robert - programme du robot 2005 {{{
+//
+// Copyright (C) 2005 Nicolas Haller
+//
+// Robot APB Team/Efrei 2005.
+// Web: http://assos.efrei.fr/robot/
+// Email: robot AT efrei DOT fr
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program 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 this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// }}}
+
+///Programme de test de la classe Vector
+
+#include "geometry/vector.hh"
+#include <iostream>
+
+int main(void)
+{
+ geometry::VectorT<int> vecInt (12,42);
+ geometry::Vector vecDouble(12.12, 42.42);
+
+ geometry::VectorT<int> testInt (12,42);
+ geometry::Vector testDouble(12.12, 42.42);
+
+ // Affichage des valeur actuelle
+
+ std::cout << "Affichage des valeurs actuelle" << std::endl;
+ std::cout << "vecInt:" << std::endl;
+ std::cout << vecInt << std::endl;
+ std::cout << "vecDouble:" << std::endl;
+ std::cout << vecDouble << std::endl;
+
+ std::cout << "Operator +=" << std::endl;
+ std::cout << "vecInt:" << std::endl;
+ std::cout << (vecInt += testInt) << std::endl;
+ std::cout << "vecDouble:" << std::endl;
+ std::cout << (vecDouble += testDouble) << std::endl;
+
+ std::cout << "Operator -=" << std::endl;
+ std::cout << "vecInt:" << std::endl;
+ std::cout << (vecInt -= testInt) << std::endl;
+ std::cout << "vecDouble:" << std::endl;
+ std::cout << (vecDouble -= testDouble) << std::endl;
+
+ std::cout << "Operator *=" << std::endl;
+ std::cout << "vecInt:" << std::endl;
+ std::cout << (vecInt *= 2) << std::endl;
+ std::cout << "vecDouble:" << std::endl;
+ std::cout << (vecDouble *= 2.0) << std::endl;
+
+ std::cout << "Operator /=" << std::endl;
+ std::cout << "vecInt:" << std::endl;
+ std::cout << (vecInt /= 2) << std::endl;
+ std::cout << "vecDouble:" << std::endl;
+ std::cout << (vecDouble /= 2.0) << std::endl;
+
+ std::cout << "Operator +" << std::endl;
+ std::cout << "vecInt:" << std::endl;
+ std::cout << (vecInt + testInt) << std::endl;
+ std::cout << "vecDouble:" << std::endl;
+ std::cout << (vecDouble + testDouble) << std::endl;
+
+ std::cout << "Operator -" << std::endl;
+ std::cout << "vecInt:" << std::endl;
+ std::cout << vecInt - testInt << std::endl;
+ std::cout << "vecDouble:" << std::endl;
+ std::cout << vecDouble - testDouble << std::endl;
+
+ std::cout << "Operator *" << std::endl;
+ std::cout << "vecInt:" << std::endl;
+ std::cout << vecInt * 2 << std::endl;
+ std::cout << "vecDouble:" << std::endl;
+ std::cout << vecDouble * 2.0 << std::endl;
+
+ std::cout << "Operator /" << std::endl;
+ std::cout << "vecInt:" << std::endl;
+ std::cout << vecInt / 2 << std::endl;
+ std::cout << "vecDouble:" << std::endl;
+ std::cout << vecDouble / 2.0 << std::endl;
+
+ std::cout << "Operator / (produit scalaire)" << std::endl;
+ std::cout << "vecInt:" << std::endl;
+ std::cout << vecInt * testInt << std::endl;
+ std::cout << "vecDouble:" << std::endl;
+ std::cout << vecDouble * testDouble << std::endl;
+
+ std::cout << "Norme" << std::endl;
+ std::cout << "vecInt:" << std::endl;
+ std::cout << vecInt.norm() << std::endl;
+ std::cout << "vecDouble:" << std::endl;
+ std::cout << vecDouble.norm() << std::endl;
+
+ std::cout << "Normalisation" << std::endl;
+ std::cout << "vecInt:" << std::endl;
+ std::cout << vecInt.normalize() << std::endl;
+ std::cout << "vecDouble:" << std::endl;
+ std::cout << vecDouble.normalize() << std::endl;
+
+ std::cout << "Rotation pi/2" << std::endl;
+ std::cout << "vecInt:" << std::endl;
+ std::cout << vecInt.rotate() << std::endl;
+ std::cout << "vecDouble:" << std::endl;
+ std::cout << vecDouble.rotate() << std::endl;
+
+ std::cout << "Rotation 2pi" << std::endl;
+ std::cout << "vecInt:" << std::endl;
+ std::cout << vecInt.rotate(static_cast<int>(2 * M_PI)) << std::endl;
+ std::cout << "vecDouble:" << std::endl;
+ std::cout << vecDouble.rotate(2 * M_PI) << std::endl;
+
+ std::cout << " distance to" << std::endl;
+ std::cout << "vecInt:" << std::endl;
+ std::cout << vecInt.distTo(testInt) << std::endl;
+ std::cout << "vecDouble:" << std::endl;
+ std::cout << vecDouble.distTo(testDouble) << std::endl;
+
+ std::cout << "sqDistTo" << std::endl;
+ std::cout << "vecInt:" << std::endl;
+ std::cout << vecInt.sqDistTo(testInt) << std::endl;
+ std::cout << "vecDouble:" << std::endl;
+ std::cout << vecDouble.sqDistTo(testDouble) << std::endl;
+}