Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
qa_vector.cpp
1 
2 /***************************************************************************
3  * qa_matrix.cpp - DESC
4  *
5  * Created: Fri Feb 17 14:31:48 2009
6  * Copyright 2009 Christof Rath <christof.rath@gmail.com>
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 /// @cond EXAMPLES
23 
24 #include <geometry/vector.h>
25 #include <utils/time/tracker.h>
26 #include <core/exceptions/software.h>
27 
28 #include <iostream>
29 #include <cmath>
30 
31 using namespace fawkes;
32 using namespace std;
33 
34 int
35 main(int argc, char **argv)
36 {
37 // TimeTracker *tt = new TimeTracker();
38 // unsigned int loop_count = 0;
39 // unsigned int ttc_trans = tt->add_class("Tra");
40 // unsigned int ttc_rot = tt->add_class("Rot");
41 // unsigned int ttc_inv = tt->add_class("Inv");
42 
43  Vector v1;
44  v1.x(1);
45  v1.y(2);
46  v1.z(3);
47 
48  cout << "v1: " << v1 << endl;
49  Vector v2 = v1 / 10;
50  cout << "v2 = v1 / 10: " << v2 << endl;
51  v1 /= 10;
52  cout << "v1 /= 10: " << v1 << endl << endl << endl;
53 
54  Vector v4;
55  v4.x(1);
56  v4.y(2);
57  v4.z(3);
58 
59  Vector v5;
60  v5.x(4);
61  v5.y(5);
62  v5.z(6);
63 
64  Vector v6(4);
65  v6.x(7);
66  v6.y(8);
67  v6.z(9);
68 
69  cout << "v4: " << v4 << " v5: " << v5 << endl;
70  Vector v7 = v4 + v5;
71  cout << "v7 = v4 + v5: " << v7 << endl;
72  v4 += v5;
73  cout << "v4 += v5: " << v4 << endl << endl;
74 
75  try {
76  Vector v8 = v4 + v6;
77  }
79  cout << e.what() << endl << endl << endl;
80  }
81 
82  try {
83  v4 += v6;
84  }
86  cout << e.what() << endl << endl << endl;
87  }
88 }
89 
90 
91 /// @endcond
float z() const
Convenience getter to obtain the third element.
Definition: vector.cpp:248
A simple column vector.
Definition: vector.h:31
float x() const
Convenience getter to obtain the first element.
Definition: vector.cpp:192
virtual const char * what() const
Get primary string.
Definition: exception.cpp:661
float y() const
Convenience getter to obtain the second element.
Definition: vector.cpp:220