Robot Devastation
Vector2dBase.hpp
1 // Authors: see AUTHORS.md at project root.
2 // CopyPolicy: released under the terms of the LGPLv2.1, see LICENSE at project root.
3 // URL: https://github.com/asrob-uc3m/robotDevastation
4 
5 #ifndef __RD_VECTOR_BASE_HPP__
6 #define __RD_VECTOR_BASE_HPP__
7 
8 namespace rd{
9 
18 template< class T>
19 class Vector2dBase {
20  public:
21  Vector2dBase( T x, T y): x(x), y(y) {}
22  Vector2dBase(): x(0), y(0) {}
23 
24  bool operator==( const Vector2dBase<T>& other_vector )
25  {
26  return x == other_vector.x && y == other_vector.y;
27  }
28 
29  Vector2dBase& operator+=( const Vector2dBase<T>&a )
30  {
31  x += a.x;
32  y += a.y;
33  return *this;
34  }
35 
36  const T & getX() const
37  {
38  return x;
39  }
40 
41  const T & getY() const
42  {
43  return y;
44  }
45 
46  private:
47  T x, y;
48 };
49 
52 
53 }
54 
55 #endif // __RD_VECTOR_BASE_HPP__
rd
The main, catch-all namespace for Robot Devastation.
Definition: groups.dox:4
rd::Vector2dBase
Class representing a 2D vector.
Definition: Vector2dBase.hpp:19
rd::Vector2d
Vector2dBase< int > Vector2d
Default 2D vector.
Definition: Vector2dBase.hpp:51