Changeset 167 in flair-src for trunk/lib/FlairCore/src/Vector2D.h
- Timestamp:
- 04/12/17 13:59:38 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairCore/src/Vector2D.h
r161 r167 21 21 * \brief Class defining a 2D vector 22 22 */ 23 template <typename T> 23 24 class Vector2D { 24 25 public: … … 31 32 * \param y 32 33 */ 33 Vector2D( float x = 0, floaty = 0);34 Vector2D(T x = 0, T y = 0); 34 35 35 36 /*! … … 73 74 * \param max maximum Vector2D value 74 75 */ 75 void Saturate(Vector2D min, Vector2Dmax);76 void Saturate(Vector2D<T> min, Vector2D<T> max); 76 77 77 78 /*! … … 92 93 * \param value saturation Vector2D value 93 94 */ 94 void Saturate(const Vector2D &value);95 void Saturate(const Vector2D<T> &value); 95 96 96 97 /*! … … 106 107 * \brief x 107 108 */ 108 floatx;109 T x; 109 110 110 111 /*! 111 112 * \brief y 112 113 */ 113 floaty;114 T y; 114 115 115 Vector2D &operator=(const Vector2D &vector); 116 Vector2D &operator+=(const Vector2D &vector); 117 Vector2D &operator-=(const Vector2D &vector); 116 template<typename S> Vector2D<T> &operator=(const Vector2D<S> &vector) { 117 x = vector.x; 118 y = vector.y; 119 return (*this); 120 } 121 Vector2D<T> &operator+=(const Vector2D<T> &vector); 122 Vector2D<T> &operator-=(const Vector2D<T> &vector); 118 123 }; 124 125 typedef Vector2D<float> Vector2Df; 119 126 120 127 /*! Add … … 125 132 * \param vectorB vector 126 133 */ 127 Vector2D operator+(const Vector2D &vectorA, const Vector2D&vectorB);134 template<typename T> Vector2D<T> operator+(const Vector2D<T> &vectorA, const Vector2D<T> &vectorB); 128 135 129 136 /*! Substract … … 134 141 * \param vectorB vector 135 142 */ 136 Vector2D operator-(const Vector2D &vectorA, const Vector2D&vectorB);143 template<typename T> Vector2D<T> operator-(const Vector2D<T> &vectorA, const Vector2D<T> &vectorB); 137 144 138 145 /*! Opposite … … 144 151 * \return -vectorA 145 152 */ 146 Vector2D operator-(const Vector2D&vectorA);153 template<typename T> Vector2D<T> operator-(const Vector2D<T> &vectorA); 147 154 148 155 /*! Divid … … 154 161 * \return vector/coefficient 155 162 */ 156 Vector2D operator/(const Vector2D&vector, float coeff);163 template<typename T> Vector2D<T> operator/(const Vector2D<T> &vector, float coeff); 157 164 158 165 /*! Multiply … … 164 171 * \return coefficient*vector 165 172 */ 166 Vector2D operator*(const Vector2D&vector, float coeff);173 template<typename T> Vector2D<T> operator*(const Vector2D<T> &vector, float coeff); 167 174 168 175 /*! Multiply … … 174 181 * \return coefficient*vector 175 182 */ 176 Vector2D operator*(float coeff, const Vector2D&vector);183 template<typename T> Vector2D<T> operator*(float coeff, const Vector2D<T> &vector); 177 184 178 185 } // end namespace core
Note:
See TracChangeset
for help on using the changeset viewer.