00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024
00025
00027 template <typename T>
00028 inline Vector2<T>::Vector2() :
00029 x(0),
00030 y(0)
00031 {
00032
00033 }
00034
00035
00037 template <typename T>
00038 inline Vector2<T>::Vector2(T X, T Y) :
00039 x(X),
00040 y(Y)
00041 {
00042
00043 }
00044
00045
00047 template <typename T>
00048 template <typename U>
00049 inline Vector2<T>::Vector2(const Vector2<U>& vector) :
00050 x(static_cast<T>(vector.x)),
00051 y(static_cast<T>(vector.y))
00052 {
00053 }
00054
00055
00057 template <typename T>
00058 inline Vector2<T> operator -(const Vector2<T>& right)
00059 {
00060 return Vector2<T>(-right.x, -right.y);
00061 }
00062
00063
00065 template <typename T>
00066 inline Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right)
00067 {
00068 left.x += right.x;
00069 left.y += right.y;
00070
00071 return left;
00072 }
00073
00074
00076 template <typename T>
00077 inline Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right)
00078 {
00079 left.x -= right.x;
00080 left.y -= right.y;
00081
00082 return left;
00083 }
00084
00085
00087 template <typename T>
00088 inline Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right)
00089 {
00090 return Vector2<T>(left.x + right.x, left.y + right.y);
00091 }
00092
00093
00095 template <typename T>
00096 inline Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right)
00097 {
00098 return Vector2<T>(left.x - right.x, left.y - right.y);
00099 }
00100
00101
00103 template <typename T>
00104 inline Vector2<T> operator *(const Vector2<T>& left, T right)
00105 {
00106 return Vector2<T>(left.x * right, left.y * right);
00107 }
00108
00109
00111 template <typename T>
00112 inline Vector2<T> operator *(T left, const Vector2<T>& right)
00113 {
00114 return Vector2<T>(right.x * left, right.y * left);
00115 }
00116
00117
00119 template <typename T>
00120 inline Vector2<T>& operator *=(Vector2<T>& left, T right)
00121 {
00122 left.x *= right;
00123 left.y *= right;
00124
00125 return left;
00126 }
00127
00128
00130 template <typename T>
00131 inline Vector2<T> operator /(const Vector2<T>& left, T right)
00132 {
00133 return Vector2<T>(left.x / right, left.y / right);
00134 }
00135
00136
00138 template <typename T>
00139 inline Vector2<T>& operator /=(Vector2<T>& left, T right)
00140 {
00141 left.x /= right;
00142 left.y /= right;
00143
00144 return left;
00145 }
00146
00147
00149 template <typename T>
00150 inline bool operator ==(const Vector2<T>& left, const Vector2<T>& right)
00151 {
00152 return (left.x == right.x) && (left.y == right.y);
00153 }
00154
00155
00157 template <typename T>
00158 inline bool operator !=(const Vector2<T>& left, const Vector2<T>& right)
00159 {
00160 return (left.x != right.x) || (left.y != right.y);
00161 }