Changeset 167 in flair-src for trunk/lib/FlairCore/src/Vector3D.h
- Timestamp:
- 04/12/17 13:59:38 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairCore/src/Vector3D.h
r15 r167 15 15 16 16 #include <stddef.h> 17 #include <Vector2D.h> 17 18 18 19 namespace flair { 19 20 namespace core { 20 class Vector2D;21 21 class RotationMatrix; 22 22 class Quaternion; … … 26 26 * \brief Class defining a 3D vector 27 27 */ 28 template <typename T> 28 29 class Vector3D { 29 30 public: … … 37 38 * \param z 38 39 */ 39 Vector3D( float x = 0, float y = 0, floatz = 0);40 Vector3D(T x = 0, T y = 0, T z = 0); 40 41 41 42 /*! … … 48 49 * \brief x 49 50 */ 50 floatx;51 T x; 51 52 52 53 /*! 53 54 * \brief y 54 55 */ 55 floaty;56 T y; 56 57 57 58 /*! 58 59 * \brief z 59 60 */ 60 floatz;61 T z; 61 62 62 63 /*! … … 126 127 * \param vector destination 127 128 */ 128 void To2Dxy(Vector2D &vector) const;129 void To2Dxy(Vector2D<T> &vector) const; 129 130 130 131 /*! … … 135 136 * \return destination 136 137 */ 137 Vector2D To2Dxy(void) const;138 Vector2D<T> To2Dxy(void) const; 138 139 139 140 /*! … … 157 158 * \param max maximum value 158 159 */ 159 void Saturate(const Vector3D &min, const Vector3D&max);160 void Saturate(const Vector3D<T> &min, const Vector3D<T> &max); 160 161 161 162 /*! … … 176 177 * \param value saturation Vector3D value 177 178 */ 178 void Saturate(const Vector3D &value);179 void Saturate(const Vector3D<T> &value); 179 180 180 181 /*! … … 188 189 void Saturate(float value); 189 190 190 float &operator[](size_t idx); 191 const float &operator[](size_t idx) const; 192 Vector3D &operator=(const Vector3D &vector); 193 Vector3D &operator+=(const Vector3D &vector); 194 Vector3D &operator-=(const Vector3D &vector); 191 T &operator[](size_t idx); 192 const T &operator[](size_t idx) const; 193 //Vector3D<T> &operator=(const Vector3D<T> &vector); 194 template<typename S> Vector3D<T> &operator=(const Vector3D<S> &vector) { 195 x = vector.x; 196 y = vector.y; 197 z = vector.z; 198 return (*this); 199 } 200 Vector3D<T> &operator+=(const Vector3D<T> &vector); 201 Vector3D<T> &operator-=(const Vector3D<T> &vector); 195 202 196 203 private: 197 204 }; 198 205 206 typedef Vector3D<float> Vector3Df; 207 199 208 /*! Add 200 209 * … … 206 215 * \return vectorA+vectorB 207 216 */ 208 Vector3D operator+(const Vector3D &vectorA, const Vector3D&vectorB);217 template<typename T> Vector3D<T> operator+(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB); 209 218 210 219 /*! Substract … … 217 226 * \return vectorA-vectorB 218 227 */ 219 Vector3D operator-(const Vector3D &vectorA, const Vector3D&vectorB);228 template<typename T> Vector3D<T> operator-(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB); 220 229 221 230 /*! Minus … … 227 236 * \return -vector 228 237 */ 229 Vector3D operator-(const Vector3D&vector);238 template<typename T> Vector3D<T> operator-(const Vector3D<T> &vector); 230 239 231 240 /*! Divid … … 238 247 * \return vector/coefficient 239 248 */ 240 Vector3D operator/(const Vector3D&vector, float coeff);249 template<typename T> Vector3D<T> operator/(const Vector3D<T> &vector, float coeff); 241 250 242 251 /*! Hadamard product … … 249 258 * \return Hadamard product 250 259 */ 251 Vector3D operator*(const Vector3D &vectorA, const Vector3D&vectorB);260 template<typename T> Vector3D<T> operator*(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB); 252 261 253 262 /*! Multiply … … 260 269 * \return coefficient*vector 261 270 */ 262 Vector3D operator*(const Vector3D&vector, float coeff);271 template<typename T> Vector3D<T> operator*(const Vector3D<T> &vector, float coeff); 263 272 264 273 /*! Multiply … … 271 280 * \return coefficient*vector 272 281 */ 273 Vector3D operator*(float coeff, const Vector3D&vector);282 template<typename T> Vector3D<T> operator*(float coeff, const Vector3D<T> &vector); 274 283 275 284 /*! Cross product … … 282 291 * \return cross product 283 292 */ 284 Vector3D CrossProduct(const Vector3D &vectorA, const Vector3D&vectorB);293 template<typename T> Vector3D<T> CrossProduct(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB); 285 294 286 295 /*! Dot product … … 293 302 * \return dot product 294 303 */ 295 float DotProduct(const Vector3D &vectorA, const Vector3D&vectorB);304 template<typename T> float DotProduct(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB); 296 305 297 306 } // end namespace core
Note:
See TracChangeset
for help on using the changeset viewer.