00001
00002
00003
00004
00005
00006
00007
00008 #ifndef _VECTOR_H
00009 #define _VECTOR_H
00010
00011 namespace ecrobot
00012 {
00013 template <class T>
00017 struct VectorT
00018 {
00019 public:
00020
00025 VectorT()
00026 : mX(T(0))
00027 , mY(T(0))
00028 {}
00029
00035 VectorT(T x, T y)
00036 : mX(x)
00037 , mY(y)
00038 {}
00039
00041 friend VectorT& operator+=(VectorT<T>& left, const VectorT<T>& right)
00042 {
00043 left.mX += right.mX;
00044 left.mY += right.mY;
00045
00046 return left;
00047 }
00049 friend VectorT& operator-=(VectorT<T>& left, const VectorT<T>& right)
00050 {
00051 left.mX -= right.mX;
00052 left.mY -= right.mY;
00053
00054 return left;
00055 }
00057 friend VectorT& operator*=(VectorT<T>& left, const VectorT<T>& right)
00058 {
00059 left.mX *= right.mX;
00060 left.mY *= right.mY;
00061
00062 return left;
00063 }
00065 friend VectorT& operator/=(VectorT<T>& left, const VectorT<T>& right)
00066 {
00067 left.mX /= right.mX;
00068 left.mY /= right.mY;
00069
00070 return left;
00071 }
00073 friend VectorT operator+(const VectorT<T>& left, const VectorT<T>& right)
00074 {
00075 left += right;
00076
00077 return left;
00078 }
00080 friend VectorT operator- (const VectorT<T>& left, const VectorT<T>& right)
00081 {
00082 left -= right;
00083
00084 return left;
00085 }
00087 friend VectorT operator*(const VectorT<T>& left, const VectorT<T>& right)
00088 {
00089 left *= right;
00090
00091 return left;
00092 }
00094 friend VectorT operator/ (const VectorT<T>& left, const VectorT<T>& right)
00095 {
00096 left /= right;
00097
00098 return left;
00099 }
00100
00102 T mX;
00104 T mY;
00105 };
00106 }
00107
00108 #endif
00109
00110