Changeset 167 in flair-src for trunk/lib/FlairCore/src/Vector2D.h


Ignore:
Timestamp:
Apr 12, 2017, 1:59:38 PM (5 years ago)
Author:
Sanahuja Guillaume
Message:

modifs pour template vectors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/Vector2D.h

    r161 r167  
    2121* \brief Class defining a 2D vector
    2222*/
     23template <typename T>
    2324class Vector2D {
    2425public:
     
    3132  * \param y
    3233  */
    33   Vector2D(float x = 0, float y = 0);
     34  Vector2D(T x = 0, T y = 0);
    3435
    3536  /*!
     
    7374  * \param max maximum Vector2D value
    7475  */
    75   void Saturate(Vector2D min, Vector2D max);
     76  void Saturate(Vector2D<T> min, Vector2D<T> max);
    7677
    7778  /*!
     
    9293  * \param value saturation Vector2D value
    9394  */
    94   void Saturate(const Vector2D &value);
     95  void Saturate(const Vector2D<T> &value);
    9596
    9697  /*!
     
    106107  * \brief x
    107108  */
    108   float x;
     109  T x;
    109110
    110111  /*!
    111112  * \brief y
    112113  */
    113   float y;
     114  T y;
    114115
    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);
    118123};
     124
     125typedef Vector2D<float> Vector2Df;
    119126
    120127/*! Add
     
    125132* \param vectorB vector
    126133*/
    127 Vector2D operator+(const Vector2D &vectorA, const Vector2D &vectorB);
     134template<typename T> Vector2D<T> operator+(const Vector2D<T> &vectorA, const Vector2D<T> &vectorB);
    128135
    129136/*! Substract
     
    134141* \param vectorB vector
    135142*/
    136 Vector2D operator-(const Vector2D &vectorA, const Vector2D &vectorB);
     143template<typename T> Vector2D<T> operator-(const Vector2D<T> &vectorA, const Vector2D<T> &vectorB);
    137144
    138145/*! Opposite
     
    144151* \return -vectorA
    145152*/
    146 Vector2D operator-(const Vector2D &vectorA);
     153template<typename T> Vector2D<T> operator-(const Vector2D<T> &vectorA);
    147154
    148155/*! Divid
     
    154161* \return vector/coefficient
    155162*/
    156 Vector2D operator/(const Vector2D &vector, float coeff);
     163template<typename T> Vector2D<T> operator/(const Vector2D<T> &vector, float coeff);
    157164
    158165/*! Multiply
     
    164171* \return coefficient*vector
    165172*/
    166 Vector2D operator*(const Vector2D &vector, float coeff);
     173template<typename T> Vector2D<T> operator*(const Vector2D<T> &vector, float coeff);
    167174
    168175/*! Multiply
     
    174181* \return coefficient*vector
    175182*/
    176 Vector2D operator*(float coeff, const Vector2D &vector);
     183template<typename T> Vector2D<T> operator*(float coeff, const Vector2D<T> &vector);
    177184
    178185} // end namespace core
Note: See TracChangeset for help on using the changeset viewer.