Changeset 50 in flair-dev for trunk/include/FlairCore/Vector2D.h
- Timestamp:
- 05/31/17 15:54:26 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/FlairCore/Vector2D.h
r13 r50 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 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); 116 123 }; 124 125 typedef Vector2D<float> Vector2Df; 117 126 118 127 /*! Add … … 123 132 * \param vectorB vector 124 133 */ 125 Vector2D operator+(const Vector2D &vectorA, const Vector2D&vectorB);134 template<typename T> Vector2D<T> operator+(const Vector2D<T> &vectorA, const Vector2D<T> &vectorB); 126 135 127 136 /*! Substract … … 132 141 * \param vectorB vector 133 142 */ 134 Vector2D operator-(const Vector2D &vectorA, const Vector2D &vectorB); 143 template<typename T> Vector2D<T> operator-(const Vector2D<T> &vectorA, const Vector2D<T> &vectorB); 144 145 /*! Opposite 146 * 147 * \brief Opposite 148 * 149 * \param vectorA vector 150 * 151 * \return -vectorA 152 */ 153 template<typename T> Vector2D<T> operator-(const Vector2D<T> &vectorA); 135 154 136 155 /*! Divid … … 142 161 * \return vector/coefficient 143 162 */ 144 Vector2D operator/(const Vector2D&vector, float coeff);163 template<typename T> Vector2D<T> operator/(const Vector2D<T> &vector, float coeff); 145 164 146 165 /*! Multiply … … 152 171 * \return coefficient*vector 153 172 */ 154 Vector2D operator*(const Vector2D&vector, float coeff);173 template<typename T> Vector2D<T> operator*(const Vector2D<T> &vector, float coeff); 155 174 156 175 /*! Multiply … … 162 181 * \return coefficient*vector 163 182 */ 164 Vector2D operator*(float coeff, const Vector2D&vector);183 template<typename T> Vector2D<T> operator*(float coeff, const Vector2D<T> &vector); 165 184 166 185 } // end namespace core
Note:
See TracChangeset
for help on using the changeset viewer.