00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef __VEC2I_H__
00031 #define __VEC2I_H__
00032
00034
00035 template <typename T>
00036 class Vec2T
00037 {
00038 public:
00039 T x;
00040 T y;
00041 };
00042
00043
00044 template <typename T>
00045 inline bool operator == (const Vec2T<T> &lhs, const Vec2T<T> &rhs)
00046 {
00047 return lhs.x == rhs.x && lhs.y == rhs.y;
00048 }
00049
00050 template <typename T>
00051 inline bool operator != (const Vec2T<T> &lhs, const Vec2T<T> &rhs)
00052 {
00053 return !(lhs == rhs);
00054 }
00055
00056 template <typename T>
00057 inline const Vec2T<T>& operator += (Vec2T<T> &lhs, const Vec2T<T>& rhs)
00058 {
00059 lhs.x += rhs.x;
00060 lhs.y += rhs.y;
00061 return lhs;
00062 }
00063
00064 template <typename T>
00065 inline const Vec2T<T>& operator -= (Vec2T<T> &lhs, const Vec2T<T> &rhs)
00066 {
00067 lhs.x -= rhs.x;
00068 lhs.y -= rhs.y;
00069 return lhs;
00070 }
00071
00072 template <typename T>
00073 inline const Vec2T<T>& operator *= (Vec2T<T> &lhs, int rhs)
00074 {
00075 lhs.x *= rhs;
00076 lhs.y *= rhs;
00077 return lhs;
00078 }
00079
00080 template <typename T>
00081 inline const Vec2T<T>& operator /= (Vec2T<T> &lhs, int rhs)
00082 {
00083 lhs.x /= rhs;
00084 lhs.y /= rhs;
00085 return lhs;
00086 }
00087
00088 template <typename T>
00089 inline Vec2T<T> operator + (const Vec2T<T> &lhs, const Vec2T<T>& rhs)
00090 {
00091 Vec2T<T> res(lhs);
00092
00093 res += rhs;
00094 return res;
00095 }
00096
00097 template <typename T>
00098 inline Vec2T<T> operator - (const Vec2T<T> &lhs, const Vec2T<T>& rhs)
00099 {
00100 Vec2T<T> res(lhs);
00101
00102 res -= rhs;
00103 return res;
00104 }
00105
00106 template <typename T>
00107 inline Vec2T<T> operator * (const Vec2T<T> &lhs, int rhs)
00108 {
00109 Vec2T<T> res(lhs);
00110
00111 res *= rhs;
00112 return res;
00113 }
00114
00115 template <typename T>
00116 inline Vec2T<T> operator * (int lhs, const Vec2T<T> &rhs)
00117 {
00118 Vec2T<T> res(rhs);
00119
00120 res *= lhs;
00121 return res;
00122 }
00123
00124 template <typename T>
00125 inline Vec2T<T> operator / (const Vec2T<T> &lhs, int rhs)
00126 {
00127 Vec2T<T> res(lhs);
00128
00129 res /= rhs;
00130 return res;
00131 }
00132
00133 typedef Vec2T<short int> Vec2i;
00134 typedef Vec2T<int> PixelPos;
00135 typedef Vec2T<int> PixelDiff;
00136 typedef Vec2T<int> PixelSize;
00137
00139
00140 #endif // !__VEC2I_H__