Changeset 167 in flair-src for trunk/lib


Ignore:
Timestamp:
04/12/17 13:59:38 (7 years ago)
Author:
Sanahuja Guillaume
Message:

modifs pour template vectors

Location:
trunk/lib
Files:
61 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/AhrsData.cpp

    r15 r167  
    4343  void CopyData(char *destination) const {
    4444    float data;
    45     Vector3D angularRates;
     45    Vector3Df angularRates;
    4646    Euler eulerAngles;
    4747    Quaternion quaternion;
     
    138138}
    139139
    140 Vector3D AhrsData::GetAngularRates(void) const {
    141   Vector3D out;
     140Vector3Df AhrsData::GetAngularRates(void) const {
     141  Vector3Df out;
    142142  GetMutex();
    143143  out = angularRates;
     
    147147
    148148void AhrsData::GetQuaternionAndAngularRates(Quaternion &outQuaternion,
    149                                             Vector3D &outAngularRates) const {
     149                                            Vector3Df &outAngularRates) const {
    150150  GetMutex();
    151151  outQuaternion = quaternion;
     
    155155
    156156void AhrsData::SetQuaternionAndAngularRates(const Quaternion &inQuaternion,
    157                                             const Vector3D &inAngularRates) {
     157                                            const Vector3Df &inAngularRates) {
    158158  GetMutex();
    159159  quaternion = inQuaternion;
     
    168168}
    169169
    170 void AhrsData::SetAngularRates(const Vector3D &inAngularRates) {
     170void AhrsData::SetAngularRates(const Vector3Df &inAngularRates) {
    171171  GetMutex();
    172172  angularRates = inAngularRates;
  • trunk/lib/FlairCore/src/AhrsData.h

    r15 r167  
    121121  *
    122122  */
    123   void SetAngularRates(const Vector3D &angularRates);
     123  void SetAngularRates(const Vector3Df &angularRates);
    124124
    125125  /*!
     
    131131  *
    132132  */
    133   Vector3D GetAngularRates(void) const;
     133  Vector3Df GetAngularRates(void) const;
    134134
    135135  /*!
     
    143143  */
    144144  void GetQuaternionAndAngularRates(Quaternion &quaternion,
    145                                     Vector3D &angularRates) const;
     145                                    Vector3Df &angularRates) const;
    146146
    147147  /*!
     
    155155  */
    156156  void SetQuaternionAndAngularRates(const Quaternion &quaternion,
    157                                     const Vector3D &angularRates);
     157                                    const Vector3Df &angularRates);
    158158
    159159  const Type &GetDataType() const { return dataType; }
     
    182182  *
    183183  */
    184   Vector3D angularRates;
     184  Vector3Df angularRates;
    185185
    186186  Type dataType;
  • trunk/lib/FlairCore/src/GpsData.h

    r51 r167  
    1919
    2020  class IODataElement;
    21   class Vector3D;
    2221
    2322/*! \class GpsData
  • trunk/lib/FlairCore/src/ImuData.cpp

    r15 r167  
    4444  void CopyData(char *dst) const {
    4545    float data;
    46     Vector3D rawAcc = imudata->GetRawAcc();
    47     Vector3D rawMag = imudata->GetRawMag();
    48     Vector3D rawGyr = imudata->GetRawGyr();
     46    Vector3Df rawAcc = imudata->GetRawAcc();
     47    Vector3Df rawMag = imudata->GetRawMag();
     48    Vector3Df rawGyr = imudata->GetRawGyr();
    4949    switch (plotableData) {
    5050    case ImuData::RawAx:
     
    121121ImuData::~ImuData() {}
    122122
    123 Vector3D ImuData::GetRawAcc(void) const {
    124   Vector3D out;
     123Vector3Df ImuData::GetRawAcc(void) const {
     124  Vector3Df out;
    125125  GetMutex();
    126126  out = rawAcc;
     
    129129}
    130130
    131 Vector3D ImuData::GetRawMag(void) const {
    132   Vector3D out;
     131Vector3Df ImuData::GetRawMag(void) const {
     132  Vector3Df out;
    133133  GetMutex();
    134134  out = rawMag;
     
    137137}
    138138
    139 Vector3D ImuData::GetRawGyr(void) const {
    140   Vector3D out;
     139Vector3Df ImuData::GetRawGyr(void) const {
     140  Vector3Df out;
    141141  GetMutex();
    142142  out = rawGyr;
     
    145145}
    146146
    147 void ImuData::GetRawAccMagAndGyr(Vector3D &inRawAcc, Vector3D &inRawMag,
    148                                  Vector3D &inRawGyr) const {
     147void ImuData::GetRawAccMagAndGyr(Vector3Df &inRawAcc, Vector3Df &inRawMag,
     148                                 Vector3Df &inRawGyr) const {
    149149  GetMutex();
    150150  inRawAcc = rawAcc;
     
    154154}
    155155
    156 void ImuData::SetRawAcc(const Vector3D &inRawAcc) {
     156void ImuData::SetRawAcc(const Vector3Df &inRawAcc) {
    157157  GetMutex();
    158158  rawAcc = inRawAcc;
     
    160160}
    161161
    162 void ImuData::SetRawMag(const Vector3D &inRawMag) {
     162void ImuData::SetRawMag(const Vector3Df &inRawMag) {
    163163  GetMutex();
    164164  rawMag = inRawMag;
     
    166166}
    167167
    168 void ImuData::SetRawGyr(const Vector3D &inRawGyr) {
     168void ImuData::SetRawGyr(const Vector3Df &inRawGyr) {
    169169  GetMutex();
    170170  rawGyr = inRawGyr;
     
    172172}
    173173
    174 void ImuData::SetRawAccMagAndGyr(const Vector3D &inRawAcc,
    175                                  const Vector3D &inRawMag,
    176                                  const Vector3D &inRawGyr) {
     174void ImuData::SetRawAccMagAndGyr(const Vector3Df &inRawAcc,
     175                                 const Vector3Df &inRawMag,
     176                                 const Vector3Df &inRawGyr) {
    177177  GetMutex();
    178178  rawAcc = inRawAcc;
  • trunk/lib/FlairCore/src/ImuData.h

    r15 r167  
    104104  *
    105105  */
    106   Vector3D GetRawAcc(void) const;
     106  Vector3Df GetRawAcc(void) const;
    107107
    108108  /*!
     
    114114  *
    115115  */
    116   Vector3D GetRawMag(void) const;
     116  Vector3Df GetRawMag(void) const;
    117117
    118118  /*!
     
    124124  *
    125125  */
    126   Vector3D GetRawGyr(void) const;
     126  Vector3Df GetRawGyr(void) const;
    127127
    128128  /*!
     
    136136  *
    137137  */
    138   void GetRawAccMagAndGyr(Vector3D &rawAcc, Vector3D &rawMag,
    139                           Vector3D &rawGyr) const;
     138  void GetRawAccMagAndGyr(Vector3Df &rawAcc, Vector3Df &rawMag,
     139                          Vector3Df &rawGyr) const;
    140140
    141141  /*!
     
    147147  *
    148148  */
    149   void SetRawAcc(const Vector3D &rawAcc);
     149  void SetRawAcc(const Vector3Df &rawAcc);
    150150
    151151  /*!
     
    157157  *
    158158  */
    159   void SetRawMag(const Vector3D &rawMag);
     159  void SetRawMag(const Vector3Df &rawMag);
    160160
    161161  /*!
     
    167167  *
    168168  */
    169   void SetRawGyr(const Vector3D &rawGyr);
     169  void SetRawGyr(const Vector3Df &rawGyr);
    170170
    171171  /*!
     
    179179  *
    180180  */
    181   void SetRawAccMagAndGyr(const Vector3D &rawAcc, const Vector3D &rawMag,
    182                           const Vector3D &rawGyr);
     181  void SetRawAccMagAndGyr(const Vector3Df &rawAcc, const Vector3Df &rawMag,
     182                          const Vector3Df &rawGyr);
    183183
    184184  Type const &GetDataType() const { return dataType; }
     
    199199  *
    200200  */
    201   Vector3D rawAcc;
     201  Vector3Df rawAcc;
    202202
    203203  /*!
     
    205205  *
    206206  */
    207   Vector3D rawGyr;
     207  Vector3Df rawGyr;
    208208
    209209  /*!
     
    211211  *
    212212  */
    213   Vector3D rawMag;
     213  Vector3Df rawMag;
    214214
    215215  void Queue(char **dst, const void *src, size_t size) const;
  • trunk/lib/FlairCore/src/OneAxisRotation.cpp

    r147 r167  
    2424#include "OneAxisRotation.h"
    2525#include "OneAxisRotation_impl.h"
    26 #include <Vector3D.h>
    2726#include <Euler.h>
    2827
     
    3231namespace core {
    3332
     33template void OneAxisRotation::ComputeRotation(core::Vector3D<float> &) const;
     34template void OneAxisRotation::ComputeRotation(core::Vector3D<double> &) const;
     35 
    3436OneAxisRotation::OneAxisRotation(const gui::LayoutPosition *position,
    3537                                 string name)
     
    4042OneAxisRotation::~OneAxisRotation() { delete pimpl_; }
    4143
    42 void OneAxisRotation::ComputeRotation(Vector3D &vector) const {
     44template <typename T> void OneAxisRotation::ComputeRotation(Vector3D<T> &vector) const {
    4345  pimpl_->ComputeRotation(vector);
    4446}
  • trunk/lib/FlairCore/src/OneAxisRotation.h

    r147 r167  
    1515
    1616#include <GroupBox.h>
     17#include <Vector3D.h>
    1718
    1819class OneAxisRotation_impl;
     
    2425
    2526namespace core {
    26 class Vector3D;
    2727class Euler;
    2828class Quaternion;
     
    5757  * \brief Compute rotation
    5858  *
    59   * \param vector Vector3D to rotate
     59  * \param vector Vector3Df to rotate
    6060  */
    61   void ComputeRotation(core::Vector3D &vector) const;
     61  template <typename T> void ComputeRotation(core::Vector3D<T> &vector) const;
    6262
    6363  /*!
  • trunk/lib/FlairCore/src/OneAxisRotation_impl.cpp

    r144 r167  
    2020#include "ComboBox.h"
    2121#include "DoubleSpinBox.h"
    22 #include <Vector3D.h>
    2322#include <Euler.h>
    2423#include <Quaternion.h>
     
    2726using namespace flair::core;
    2827using namespace flair::gui;
     28
     29template void OneAxisRotation_impl::ComputeRotation(Vector3D<float>&) const;
     30template void OneAxisRotation_impl::ComputeRotation(Vector3D<double>&) const;
    2931
    3032OneAxisRotation_impl::OneAxisRotation_impl(GroupBox *box) {
     
    4143// compute rotation of each axis through ComputeRotation(Vector3D& vector)
    4244void OneAxisRotation_impl::ComputeRotation(Quaternion &quat) const {
    43   Vector3D rot = Vector3D(quat.q1, quat.q2, quat.q3);
     45  Vector3Df rot = Vector3Df(quat.q1, quat.q2, quat.q3);
    4446  ComputeRotation(rot);
    4547  quat.q1 = rot.x;
     
    5456// on utilise la rotation d'un vector pour faire une rotation de repere
    5557// d'ou le signe negatif
    56 void OneAxisRotation_impl::ComputeRotation(Vector3D &vector) const {
     58template <typename T> void OneAxisRotation_impl::ComputeRotation(Vector3D<T> &vector) const {
    5759  switch (rot_axe->CurrentIndex()) {
    5860  case 0:
  • trunk/lib/FlairCore/src/Quaternion.cpp

    r161 r167  
    1717
    1818#include "Quaternion.h"
    19 #include "Vector3D.h"
    2019#include "Euler.h"
    2120#include "RotationMatrix.h"
     
    6362}
    6463
    65 void Quaternion::GetLogarithm(Vector3D &logarithm) {
     64void Quaternion::GetLogarithm(Vector3Df &logarithm) {
    6665  Normalize();
    6766  float v_norm = sqrtf(q1 * q1 + q2 * q2 + q3 * q3);
     
    7978}
    8079
    81 Vector3D Quaternion::GetLogarithm(void) {
    82   Vector3D vector;
     80Vector3Df Quaternion::GetLogarithm(void) {
     81  Vector3Df vector;
    8382  GetLogarithm(vector);
    8483  return vector;
    8584}
    8685
    87 Quaternion Quaternion::GetDerivative(const Vector3D &angularSpeed) const {
     86Quaternion Quaternion::GetDerivative(const Vector3Df &angularSpeed) const {
    8887  const Quaternion Qw(0, angularSpeed.x, angularSpeed.y, angularSpeed.z);
    8988  return 0.5 * (*this) * Qw;
    9089}
    9190
    92 void Quaternion::Derivate(const Vector3D &angularSpeed) {
     91void Quaternion::Derivate(const Vector3Df &angularSpeed) {
    9392  Quaternion Q = GetDerivative(angularSpeed);
    9493  (*this) = Q;
  • trunk/lib/FlairCore/src/Quaternion.h

    r15 r167  
    1313#define QUATERNION_H
    1414
     15#include <Vector3D.h>
     16
    1517namespace flair {
    1618namespace core {
    1719class Euler;
    18 class Vector3D;
    1920class RotationMatrix;
    2021
     
    6263  * \param logarithm output logarithm
    6364  */
    64   void GetLogarithm(Vector3D &logarithm);
     65  void GetLogarithm(Vector3Df &logarithm);
    6566
    6667  /*!
     
    7172  * \return output logarithm
    7273  */
    73   Vector3D GetLogarithm(void);
     74  Vector3Df GetLogarithm(void);
    7475
    7576  /*!
     
    9293  * \return derivative
    9394  */
    94   Quaternion GetDerivative(const Vector3D &angularSpeed) const;
     95  Quaternion GetDerivative(const Vector3Df &angularSpeed) const;
    9596
    9697  /*!
     
    99100  * \param w rotationonal speed
    100101  */
    101   void Derivate(const Vector3D &angularSpeed);
     102  void Derivate(const Vector3Df &angularSpeed);
    102103
    103104  /*!
  • trunk/lib/FlairCore/src/Vector2D.cpp

    r161 r167  
    2222namespace flair {
    2323namespace core {
     24 
     25template class Vector2D<double>;
     26template Vector2D<double> operator+(const Vector2D<double>&, const Vector2D<double>&);
     27template Vector2D<double> operator-(const Vector2D<double>&, const Vector2D<double>&);
     28template Vector2D<double> operator-(const Vector2D<double>&);
     29template Vector2D<double> operator/(const Vector2D<double>&, float);
     30template Vector2D<double> operator*(const Vector2D<double>&, float);
     31template Vector2D<double> operator*(float, const Vector2D<double>&);
    2432
    25 Vector2D::Vector2D(float inX, float inY) : x(inX), y(inY) {}
     33template class Vector2D<float>;
     34template Vector2D<float> operator+(const Vector2D<float>&, const Vector2D<float>&);
     35template Vector2D<float> operator-(const Vector2D<float>&, const Vector2D<float>&);
     36template Vector2D<float> operator-(const Vector2D<float>&);
     37template Vector2D<float> operator/(const Vector2D<float>&, float);
     38template Vector2D<float> operator*(const Vector2D<float>&, float);
     39template Vector2D<float> operator*(float, const Vector2D<float>&);
    2640
    27 Vector2D::~Vector2D() {}
     41template <typename T> Vector2D<T>::Vector2D(T inX, T inY) : x(inX), y(inY) {}
    2842
    29 Vector2D &Vector2D::operator=(const Vector2D &vector) {
    30   x = vector.x;
    31   y = vector.y;
    32   return (*this);
    33 }
     43template <typename T> Vector2D<T>::~Vector2D() {}
    3444
    35 Vector2D &Vector2D::operator+=(const Vector2D &vector) {
     45template <typename T> Vector2D<T> &Vector2D<T>::operator+=(const Vector2D<T> &vector) {
    3646  x += vector.x;
    3747  y += vector.y;
     
    3949}
    4050
    41 Vector2D &Vector2D::operator-=(const Vector2D &vector) {
     51template <typename T> Vector2D<T> &Vector2D<T>::operator-=(const Vector2D<T> &vector) {
    4252  x -= vector.x;
    4353  y -= vector.y;
     
    4555}
    4656
    47 Vector2D operator+(const Vector2D &vectorA, const Vector2D &vectorB) {
    48   return Vector2D(vectorA.x + vectorB.x, vectorA.y + vectorB.y);
     57template <typename T> Vector2D<T> operator+(const Vector2D<T> &vectorA, const Vector2D<T> &vectorB) {
     58  return Vector2D<T>(vectorA.x + vectorB.x, vectorA.y + vectorB.y);
    4959}
    5060
    51 Vector2D operator-(const Vector2D &vectorA, const Vector2D &vectorB) {
    52   return Vector2D(vectorA.x - vectorB.x, vectorA.y - vectorB.y);
     61template <typename T> Vector2D<T> operator-(const Vector2D<T> &vectorA, const Vector2D<T> &vectorB) {
     62  return Vector2D<T>(vectorA.x - vectorB.x, vectorA.y - vectorB.y);
    5363}
    5464
    55 Vector2D operator-(const Vector2D &vectorA) {
    56  return Vector2D(-vectorA.x, -vectorA.y);
     65template <typename T> Vector2D<T> operator-(const Vector2D<T> &vectorA) {
     66 return Vector2D<T>(-vectorA.x, -vectorA.y);
    5767}
    5868
    59 Vector2D operator/(const Vector2D &vector, float coeff) {
     69template <typename T> Vector2D<T> operator/(const Vector2D<T> &vector, float coeff) {
    6070  if (coeff != 0) {
    61     return Vector2D(vector.x / coeff, vector.y / coeff);
     71    return Vector2D<T>(vector.x / coeff, vector.y / coeff);
    6272  } else {
    63     return Vector2D(0, 0);
     73    return Vector2D<T>(0, 0);
    6474  }
    6575}
    6676
    67 Vector2D operator*(const Vector2D &vector, float coeff) {
    68   return Vector2D(vector.x * coeff, vector.y * coeff);
     77template <typename T> Vector2D<T> operator*(const Vector2D<T> &vector, float coeff) {
     78  return Vector2D<T>(vector.x * coeff, vector.y * coeff);
    6979}
    7080
    71 Vector2D operator*(float coeff, const Vector2D &vector) {
    72   return Vector2D(vector.x * coeff, vector.y * coeff);
     81template <typename T> Vector2D<T> operator*(float coeff, const Vector2D<T> &vector) {
     82  return Vector2D<T>(vector.x * coeff, vector.y * coeff);
    7383}
    7484
    75 void Vector2D::Rotate(float value) {
     85template <typename T> void Vector2D<T>::Rotate(float value) {
    7686  float xTmp;
    7787  xTmp = x * cosf(value) - y * sinf(value);
     
    8090}
    8191
    82 void Vector2D::RotateDeg(float value) { Rotate(Euler::ToRadian(value)); }
     92template <typename T> void Vector2D<T>::RotateDeg(float value) { Rotate(Euler::ToRadian(value)); }
    8393
    84 float Vector2D::GetNorm(void) const { return sqrt(x * x + y * y); }
     94template <typename T> float Vector2D<T>::GetNorm(void) const { return sqrt(x * x + y * y); }
    8595
    86 void Vector2D::Normalize(void) {
     96template <typename T> void Vector2D<T>::Normalize(void) {
    8797  float n = GetNorm();
    8898  if (n != 0) {
     
    92102}
    93103
    94 void Vector2D::Saturate(Vector2D min, Vector2D max) {
     104template <typename T> void Vector2D<T>::Saturate(Vector2D min, Vector2D max) {
    95105  if (x < min.x)
    96106    x = min.x;
     
    104114}
    105115
    106 void Vector2D::Saturate(float min, float max) {
     116template <typename T> void Vector2D<T>::Saturate(float min, float max) {
    107117  Saturate(Vector2D(min, min), Vector2D(max, max));
    108118}
    109119
    110 void Vector2D::Saturate(const Vector2D &value) {
     120template <typename T> void Vector2D<T>::Saturate(const Vector2D &value) {
    111121  float x = fabs(value.x);
    112122  float y = fabs(value.y);
     
    114124}
    115125
    116 void Vector2D::Saturate(float value) {
     126template <typename T> void Vector2D<T>::Saturate(float value) {
    117127  float sat = fabs(value);
    118128  Saturate(Vector2D(-sat, -sat), Vector2D(sat, sat));
  • 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
  • trunk/lib/FlairCore/src/Vector3D.cpp

    r15 r167  
    2323#include "Object.h"
    2424#include <math.h>
    25 //#include "Vector3DSpinBox.h"
    2625
    2726namespace flair {
    2827namespace core {
    29 
    30 Vector3D::Vector3D(float inX, float inY, float inZ) : x(inX), y(inY), z(inZ) {}
    31 
    32 Vector3D::~Vector3D() {}
     28 
     29template class Vector3D<double>;
     30template Vector3D<double> operator+(const Vector3D<double>&, const Vector3D<double>&);
     31template Vector3D<double> operator-(const Vector3D<double>&, const Vector3D<double>&);
     32template Vector3D<double> operator-(const Vector3D<double>&);
     33template Vector3D<double> operator/(const Vector3D<double>&, float);
     34template Vector3D<double> operator*(const Vector3D<double>&, const Vector3D<double>&);
     35template Vector3D<double> operator*(const Vector3D<double>&, float);
     36template Vector3D<double> operator*(float, const Vector3D<double>&);
     37template Vector3D<double> CrossProduct(const Vector3D<double>&, const Vector3D<double>&);
     38template float DotProduct(const Vector3D<double>&, const Vector3D<double>&);
     39
     40template class Vector3D<float>;
     41template Vector3D<float> operator+(const Vector3D<float>&, const Vector3D<float>&);
     42template Vector3D<float> operator-(const Vector3D<float>&, const Vector3D<float>&);
     43template Vector3D<float> operator-(const Vector3D<float>&);
     44template Vector3D<float> operator/(const Vector3D<float>&, float);
     45template Vector3D<float> operator*(const Vector3D<float>&, const Vector3D<float>&);
     46template Vector3D<float> operator*(const Vector3D<float>&, float);
     47template Vector3D<float> operator*(float, const Vector3D<float>&);
     48template Vector3D<float> CrossProduct(const Vector3D<float>&, const Vector3D<float>&);
     49template float DotProduct(const Vector3D<float>&, const Vector3D<float>&);
     50
     51template <typename T> Vector3D<T>::Vector3D(T inX, T inY, T inZ) {
     52  x=inX;
     53  y=inY;
     54  z=inZ;
     55}
     56
     57template <typename T> Vector3D<T>::~Vector3D() {}
     58
    3359/*
    3460void Vector3D::operator=(const gui::Vector3DSpinBox *vector) {
     
    3864    z=vect.z;
    3965}*/
    40 
    41 Vector3D &Vector3D::operator=(const Vector3D &vector) {
     66/*
     67template<typename T,typename S> Vector3D<T> &Vector3D<T>::operator=(const Vector3D<S> &vector) {
     68//template <typename T> Vector3D<T> &Vector3D<T>::operator=(const Vector3D<T> &vector) {
    4269  x = vector.x;
    4370  y = vector.y;
     
    4572  return (*this);
    4673}
    47 
    48 Vector3D &Vector3D::operator+=(const Vector3D &vector) {
     74*/
     75template <typename T> Vector3D<T> &Vector3D<T>::operator+=(const Vector3D<T> &vector) {
    4976  x += vector.x;
    5077  y += vector.y;
     
    5380}
    5481
    55 Vector3D &Vector3D::operator-=(const Vector3D &vector) {
     82template <typename T> Vector3D<T> &Vector3D<T>::operator-=(const Vector3D<T> &vector) {
    5683  x -= vector.x;
    5784  y -= vector.y;
     
    6087}
    6188
    62 float &Vector3D::operator[](size_t idx) {
     89template <typename T> T &Vector3D<T>::operator[](size_t idx) {
    6390  if (idx == 0) {
    6491    return x;
     
    73100}
    74101
    75 const float &Vector3D::operator[](size_t idx) const {
     102template <typename T> const T &Vector3D<T>::operator[](size_t idx) const {
    76103  if (idx == 0) {
    77104    return x;
     
    86113}
    87114
    88 Vector3D CrossProduct(const Vector3D &vectorA, const Vector3D &vectorB) {
    89   return Vector3D(vectorA.y * vectorB.z - vectorA.z * vectorB.y,
     115template <typename T> Vector3D<T> CrossProduct(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB) {
     116  return Vector3D<T>(vectorA.y * vectorB.z - vectorA.z * vectorB.y,
    90117                  vectorA.z * vectorB.x - vectorA.x * vectorB.z,
    91118                  vectorA.x * vectorB.y - vectorA.y * vectorB.x);
    92119}
    93120
    94 float DotProduct(const Vector3D &vectorA, const Vector3D &vectorB) {
     121template <typename T> float DotProduct(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB) {
    95122  return vectorA.x * vectorB.x + vectorA.y * vectorB.y + vectorA.z * vectorB.z;
    96123}
    97124
    98 Vector3D operator+(const Vector3D &vectorA, const Vector3D &vectorB) {
    99   return Vector3D(vectorA.x + vectorB.x, vectorA.y + vectorB.y,
     125template <typename T> Vector3D<T> operator+(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB) {
     126  return Vector3D<T>(vectorA.x + vectorB.x, vectorA.y + vectorB.y,
    100127                  vectorA.z + vectorB.z);
    101128}
    102129
    103 Vector3D operator-(const Vector3D &vectorA, const Vector3D &vectorB) {
    104   return Vector3D(vectorA.x - vectorB.x, vectorA.y - vectorB.y,
     130template <typename T> Vector3D<T> operator-(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB) {
     131  return Vector3D<T>(vectorA.x - vectorB.x, vectorA.y - vectorB.y,
    105132                  vectorA.z - vectorB.z);
    106133}
    107134
    108 Vector3D operator-(const Vector3D &vector) {
    109   return Vector3D(-vector.x, -vector.y, -vector.z);
    110 }
    111 
    112 Vector3D operator*(const Vector3D &vectorA, const Vector3D &vectorB) {
    113   return Vector3D(vectorA.x * vectorB.x, vectorA.y * vectorB.y,
     135template <typename T> Vector3D<T> operator-(const Vector3D<T> &vector) {
     136  return Vector3D<T>(-vector.x, -vector.y, -vector.z);
     137}
     138
     139template <typename T> Vector3D<T> operator*(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB) {
     140  return Vector3D<T>(vectorA.x * vectorB.x, vectorA.y * vectorB.y,
    114141                  vectorA.z * vectorB.z);
    115142}
    116143
    117 Vector3D operator*(const Vector3D &vector, float coeff) {
    118   return Vector3D(vector.x * coeff, vector.y * coeff, vector.z * coeff);
    119 }
    120 
    121 Vector3D operator*(float coeff, const Vector3D &vector) {
    122   return Vector3D(vector.x * coeff, vector.y * coeff, vector.z * coeff);
    123 }
    124 
    125 Vector3D operator/(const Vector3D &vector, float coeff) {
     144template <typename T> Vector3D<T> operator*(const Vector3D<T> &vector, float coeff) {
     145  return Vector3D<T>(vector.x * coeff, vector.y * coeff, vector.z * coeff);
     146}
     147
     148template <typename T> Vector3D<T> operator*(float coeff, const Vector3D<T> &vector) {
     149  return Vector3D<T>(vector.x * coeff, vector.y * coeff, vector.z * coeff);
     150}
     151
     152template <typename T> Vector3D<T> operator/(const Vector3D<T> &vector, float coeff) {
    126153  if (coeff != 0) {
    127     return Vector3D(vector.x / coeff, vector.y / coeff, vector.z / coeff);
     154    return Vector3D<T>(vector.x / coeff, vector.y / coeff, vector.z / coeff);
    128155  } else {
    129156    printf("Vector3D: err divinding by 0\n");
    130     return Vector3D(0, 0, 0);
    131   }
    132 }
    133 
    134 void Vector3D::RotateX(float value) {
     157    return Vector3D<T>(0, 0, 0);
     158  }
     159}
     160
     161template <typename T> void Vector3D<T>::RotateX(float value) {
    135162  float y_tmp;
    136163  y_tmp = y * cosf(value) - z * sinf(value);
     
    139166}
    140167
    141 void Vector3D::RotateXDeg(float value) { RotateX(Euler::ToRadian(value)); }
    142 
    143 void Vector3D::RotateY(float value) {
     168template <typename T> void Vector3D<T>::RotateXDeg(float value) { RotateX(Euler::ToRadian(value)); }
     169
     170template <typename T> void Vector3D<T>::RotateY(float value) {
    144171  float x_tmp;
    145172  x_tmp = x * cosf(value) + z * sinf(value);
     
    148175}
    149176
    150 void Vector3D::RotateYDeg(float value) { RotateY(Euler::ToRadian(value)); }
    151 
    152 void Vector3D::RotateZ(float value) {
     177template <typename T> void Vector3D<T>::RotateYDeg(float value) { RotateY(Euler::ToRadian(value)); }
     178
     179template <typename T> void Vector3D<T>::RotateZ(float value) {
    153180  float x_tmp;
    154181  x_tmp = x * cosf(value) - y * sinf(value);
     
    157184}
    158185
    159 void Vector3D::RotateZDeg(float value) { RotateZ(Euler::ToRadian(value)); }
    160 
    161 void Vector3D::Rotate(const RotationMatrix &matrix) {
    162   float a[3] = {0, 0, 0};
    163   float b[3] = {x, y, z};
     186template <typename T> void Vector3D<T>::RotateZDeg(float value) { RotateZ(Euler::ToRadian(value)); }
     187
     188template <typename T> void Vector3D<T>::Rotate(const RotationMatrix &matrix) {
     189  T a[3] = {0, 0, 0};
     190  T b[3] = {x, y, z};
    164191
    165192  for (int i = 0; i < 3; i++) {
     
    174201}
    175202
    176 void Vector3D::Rotate(const Quaternion &quaternion) {
     203template <typename T> void Vector3D<T>::Rotate(const Quaternion &quaternion) {
    177204  RotationMatrix matrix;
    178205  quaternion.ToRotationMatrix(matrix);
     
    180207}
    181208
    182 void Vector3D::To2Dxy(Vector2D &vector) const {
     209template <typename T> void Vector3D<T>::To2Dxy(Vector2D<T> &vector) const {
    183210  vector.x = x;
    184211  vector.y = y;
    185212}
    186213
    187 Vector2D Vector3D::To2Dxy(void) const {
    188   Vector2D vect;
     214template <typename T> Vector2D<T> Vector3D<T>::To2Dxy(void) const {
     215  Vector2D<T> vect;
    189216  To2Dxy(vect);
    190217  return vect;
    191218}
    192219
    193 float Vector3D::GetNorm(void) const { return sqrt(x * x + y * y + z * z); }
    194 
    195 void Vector3D::Normalize(void) {
     220template <typename T> float Vector3D<T>::GetNorm(void) const { return sqrt(x * x + y * y + z * z); }
     221
     222template <typename T> void Vector3D<T>::Normalize(void) {
    196223  float n = GetNorm();
    197224  if (n != 0) {
     
    202229}
    203230
    204 void Vector3D::Saturate(const Vector3D &min, const Vector3D &max) {
     231template <typename T> void Vector3D<T>::Saturate(const Vector3D<T> &min, const Vector3D<T> &max) {
    205232  if (x < min.x)
    206233    x = min.x;
     
    219246}
    220247
    221 void Vector3D::Saturate(float min, float max) {
    222   Saturate(Vector3D(min, min, min), Vector3D(max, max, max));
    223 }
    224 
    225 void Vector3D::Saturate(const Vector3D &value) {
     248template <typename T> void Vector3D<T>::Saturate(float min, float max) {
     249  Saturate(Vector3D<T>(min, min, min), Vector3D<T>(max, max, max));
     250}
     251
     252template <typename T> void Vector3D<T>::Saturate(const Vector3D<T> &value) {
    226253  float x = fabs(value.x);
    227254  float y = fabs(value.y);
    228255  float z = fabs(value.z);
    229   Saturate(Vector3D(-x, -y, -z), Vector3D(x, y, z));
    230 }
    231 
    232 void Vector3D::Saturate(float value) {
     256  Saturate(Vector3D<T>(-x, -y, -z), Vector3D<T>(x, y, z));
     257}
     258
     259template <typename T> void Vector3D<T>::Saturate(float value) {
    233260  float sat = fabs(value);
    234   Saturate(Vector3D(-sat, -sat, -sat), Vector3D(sat, sat, sat));
     261  Saturate(Vector3D<T>(-sat, -sat, -sat), Vector3D<T>(sat, sat, sat));
    235262}
    236263
  • trunk/lib/FlairCore/src/Vector3D.h

    r15 r167  
    1515
    1616#include <stddef.h>
     17#include <Vector2D.h>
    1718
    1819namespace flair {
    1920namespace core {
    20 class Vector2D;
    2121class RotationMatrix;
    2222class Quaternion;
     
    2626* \brief Class defining a 3D vector
    2727*/
     28template <typename T>
    2829class Vector3D {
    2930public:
     
    3738  * \param z
    3839  */
    39   Vector3D(float x = 0, float y = 0, float z = 0);
     40  Vector3D(T x = 0, T y = 0, T z = 0);
    4041
    4142  /*!
     
    4849  * \brief x
    4950  */
    50   float x;
     51  T x;
    5152
    5253  /*!
    5354  * \brief y
    5455  */
    55   float y;
     56  T y;
    5657
    5758  /*!
    5859  * \brief z
    5960  */
    60   float z;
     61  T z;
    6162
    6263  /*!
     
    126127  * \param vector destination
    127128  */
    128   void To2Dxy(Vector2D &vector) const;
     129  void To2Dxy(Vector2D<T> &vector) const;
    129130
    130131  /*!
     
    135136  * \return destination
    136137  */
    137   Vector2D To2Dxy(void) const;
     138  Vector2D<T> To2Dxy(void) const;
    138139
    139140  /*!
     
    157158  * \param max maximum value
    158159  */
    159   void Saturate(const Vector3D &min, const Vector3D &max);
     160  void Saturate(const Vector3D<T> &min, const Vector3D<T> &max);
    160161
    161162  /*!
     
    176177  * \param value saturation Vector3D value
    177178  */
    178   void Saturate(const Vector3D &value);
     179  void Saturate(const Vector3D<T> &value);
    179180
    180181  /*!
     
    188189  void Saturate(float value);
    189190
    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);
    195202
    196203private:
    197204};
    198205
     206typedef Vector3D<float> Vector3Df;
     207
    199208/*! Add
    200209*
     
    206215* \return vectorA+vectorB
    207216*/
    208 Vector3D operator+(const Vector3D &vectorA, const Vector3D &vectorB);
     217template<typename T> Vector3D<T> operator+(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB);
    209218
    210219/*! Substract
     
    217226* \return vectorA-vectorB
    218227*/
    219 Vector3D operator-(const Vector3D &vectorA, const Vector3D &vectorB);
     228template<typename T> Vector3D<T> operator-(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB);
    220229
    221230/*! Minus
     
    227236* \return -vector
    228237*/
    229 Vector3D operator-(const Vector3D &vector);
     238template<typename T> Vector3D<T> operator-(const Vector3D<T> &vector);
    230239
    231240/*! Divid
     
    238247* \return vector/coefficient
    239248*/
    240 Vector3D operator/(const Vector3D &vector, float coeff);
     249template<typename T> Vector3D<T> operator/(const Vector3D<T> &vector, float coeff);
    241250
    242251/*! Hadamard product
     
    249258* \return Hadamard product
    250259*/
    251 Vector3D operator*(const Vector3D &vectorA, const Vector3D &vectorB);
     260template<typename T> Vector3D<T> operator*(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB);
    252261
    253262/*! Multiply
     
    260269* \return coefficient*vector
    261270*/
    262 Vector3D operator*(const Vector3D &vector, float coeff);
     271template<typename T> Vector3D<T> operator*(const Vector3D<T> &vector, float coeff);
    263272
    264273/*! Multiply
     
    271280* \return coefficient*vector
    272281*/
    273 Vector3D operator*(float coeff, const Vector3D &vector);
     282template<typename T> Vector3D<T> operator*(float coeff, const Vector3D<T> &vector);
    274283
    275284/*! Cross product
     
    282291* \return cross product
    283292*/
    284 Vector3D CrossProduct(const Vector3D &vectorA, const Vector3D &vectorB);
     293template<typename T> Vector3D<T> CrossProduct(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB);
    285294
    286295/*! Dot product
     
    293302* \return dot product
    294303*/
    295 float DotProduct(const Vector3D &vectorA, const Vector3D &vectorB);
     304template<typename T> float DotProduct(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB);
    296305
    297306} // end namespace core
  • trunk/lib/FlairCore/src/Vector3DSpinBox.cpp

    r15 r167  
    2626Vector3DSpinBox::Vector3DSpinBox(const LayoutPosition *position, string name,
    2727                                 double min, double max, double step,
    28                                  int decimals, core::Vector3D default_value)
     28                                 int decimals, core::Vector3Df default_value)
    2929    : Box(position, name, "Vector3DSpinBox") {
    3030  // update value from xml file
     
    5252}
    5353*/
    54 core::Vector3D Vector3DSpinBox::Value(void) const {
    55   core::Vector3D tmp;
     54core::Vector3Df Vector3DSpinBox::Value(void) const {
     55  core::Vector3Df tmp;
    5656
    5757  GetMutex();
  • trunk/lib/FlairCore/src/Vector3DSpinBox.h

    r15 r167  
    4444  Vector3DSpinBox(const LayoutPosition *position, std::string name, double min,
    4545                  double max, double step, int decimals = 2,
    46                   core::Vector3D default_value = core::Vector3D(0, 0, 0));
     46                  core::Vector3Df default_value = core::Vector3Df(0, 0, 0));
    4747
    4848  /*!
     
    5757  * \return value
    5858  */
    59   core::Vector3D Value(void) const;
     59  core::Vector3Df Value(void) const;
    6060  // operator core::Vector3D() const;
    6161private:
     
    6868  void XmlEvent(void);
    6969
    70   core::Vector3D box_value;
     70  core::Vector3Df box_value;
    7171};
    7272
  • trunk/lib/FlairCore/src/Vector3Ddata.h

    r15 r167  
    2626* User must manually use the io_data's Mutex to access to Vector3D values.
    2727*/
    28 class Vector3Ddata : public io_data, public Vector3D {
     28class Vector3Ddata : public io_data, public Vector3Df {
    2929public:
    3030  /*!
  • trunk/lib/FlairCore/src/unexported/OneAxisRotation_impl.h

    r144 r167  
    1414#define ONEAXISROTATION_IMPL_H
    1515
     16#include <Vector3D.h>
     17
    1618namespace flair {
    1719namespace core {
    18 class Vector3D;
    1920class Euler;
    2021class Quaternion;
     
    3637  OneAxisRotation_impl(flair::gui::GroupBox *box);
    3738  ~OneAxisRotation_impl();
    38   void ComputeRotation(flair::core::Vector3D &point) const;
     39  template <typename T> void ComputeRotation(flair::core::Vector3D<T> &point) const;
    3940  void ComputeRotation(flair::core::Quaternion &quat) const;
    4041  void ComputeRotation(flair::core::RotationMatrix &matrix) const;
  • trunk/lib/FlairFilter/src/Ahrs.h

    r51 r167  
    1919namespace flair {
    2020  namespace core {
    21     class Euler;
    22     class Vector3D;
    23     class ImuData;
    24     class Quaternion;
    2521    class AhrsData;
    2622  }
  • trunk/lib/FlairFilter/src/AhrsComplementaryFilter.cpp

    r157 r167  
    6464    AhrsData* ahrsData;
    6565    GetDatas(&ahrsData);
    66     Vector3D rawAcc,rawMag,rawGyr;
     66    Vector3Df rawAcc,rawMag,rawGyr;
    6767    input->GetRawAccMagAndGyr(rawAcc,rawMag,rawGyr);
    6868
     
    7070    previous_time=data->DataTime();
    7171
    72     Vector3D aBar,aHat,aTilde;
    73     Vector3D mBar,mHat,mTilde;
    74     Vector3D alpha,dBHat,omegaHat;
     72    Vector3Df aBar,aHat,aTilde;
     73    Vector3Df mBar,mHat,mTilde;
     74    Vector3Df alpha,dBHat,omegaHat;
    7575    Quaternion dQHat;
    7676
  • trunk/lib/FlairFilter/src/AhrsComplementaryFilter.h

    r24 r167  
    6666            bool isInit;
    6767            core::Quaternion QHat;
    68             core::Vector3D BHat;
     68            core::Vector3Df BHat;
    6969            gui::DoubleSpinBox *ka[3];
    7070            gui::DoubleSpinBox *kb[3];
  • trunk/lib/FlairFilter/src/AhrsKalman_impl.cpp

    r18 r167  
    8686    ImuData *input=(ImuData*)data;
    8787    float delta_t;
    88     Vector3D rawAcc,rawMag,rawGyr;
     88    Vector3Df rawAcc,rawMag,rawGyr;
    8989
    9090    input->GetRawAccMagAndGyr(rawAcc,rawMag,rawGyr);
     
    115115
    116116        ahrsData->SetQuaternionAndAngularRates(euler.ToQuaternion(),
    117                                                rawGyr-Vector3D(ars_roll.x_bias,ars_pitch.x_bias,0));
     117                                               rawGyr-Vector3Df(ars_roll.x_bias,ars_pitch.x_bias,0));
    118118    } else {
    119119        is_init=true;
  • trunk/lib/FlairFilter/src/Gx3_25_ahrs.cpp

    r157 r167  
    4444
    4545  Quaternion quaternion;
    46   Vector3D filteredAngRates;
     46  Vector3Df filteredAngRates;
    4747  input->GetQuaternionAndAngularRates(quaternion, filteredAngRates);
    4848  GetImu()->GetOneAxisRotation()->ComputeRotation(quaternion);
  • trunk/lib/FlairFilter/src/JoyReference_impl.cpp

    r148 r167  
    168168  input->GetMutex();
    169169
    170   Vector3D theta_xy(
     170  Vector3Df theta_xy(
    171171      -Euler::ToRadian(input->ValueNoMutex(0, 0) * deb_roll->Value()),
    172172      -Euler::ToRadian(input->ValueNoMutex(1, 0) * deb_pitch->Value()), 0);
    173   Vector3D e_bar = theta_xy;
     173  Vector3Df e_bar = theta_xy;
    174174  e_bar.Normalize();
    175175  Quaternion q_xy(cos(theta_xy.GetNorm() / 2.0f),
     
    192192  input->ReleaseMutex();
    193193
    194   ahrsData->SetQuaternionAndAngularRates(q_ref, Vector3D(0, 0, wz_ref));
     194  ahrsData->SetQuaternionAndAngularRates(q_ref, Vector3Df(0, 0, wz_ref));
    195195
    196196  // ouput quaternion for control law
  • trunk/lib/FlairFilter/src/SimuAhrs.cpp

    r158 r167  
    4242
    4343  Quaternion quaternion;
    44   Vector3D filteredAngRates;
     44  Vector3Df filteredAngRates;
    4545  input->GetQuaternionAndAngularRates(quaternion, filteredAngRates);
    4646  output->SetQuaternionAndAngularRates(quaternion, filteredAngRates);
  • trunk/lib/FlairFilter/src/TrajectoryGenerator2DCircle.cpp

    r157 r167  
    4848}
    4949
    50 void TrajectoryGenerator2DCircle::StartTraj(const Vector2D &start_pos,
     50void TrajectoryGenerator2DCircle::StartTraj(const Vector2Df &start_pos,
    5151                                            float nb_lap) {
    5252  pimpl_->StartTraj(start_pos, nb_lap);
     
    5757void TrajectoryGenerator2DCircle::StopTraj(void) { pimpl_->is_running = false; }
    5858
    59 void TrajectoryGenerator2DCircle::GetPosition(Vector2D &point) const {
     59void TrajectoryGenerator2DCircle::GetPosition(Vector2Df &point) const {
    6060  point.x = pimpl_->output->Value(0, 0);
    6161  point.y = pimpl_->output->Value(0, 1);
    6262}
    6363
    64 void TrajectoryGenerator2DCircle::SetCenter(const Vector2D &value) {
     64void TrajectoryGenerator2DCircle::SetCenter(const Vector2Df &value) {
    6565  pimpl_->pos_off = value;
    6666}
    6767
    68 void TrajectoryGenerator2DCircle::GetSpeed(Vector2D &point) const {
     68void TrajectoryGenerator2DCircle::GetSpeed(Vector2Df &point) const {
    6969  point.x = pimpl_->output->Value(1, 0);
    7070  point.y = pimpl_->output->Value(1, 1);
    7171}
    7272
    73 void TrajectoryGenerator2DCircle::SetCenterSpeed(const Vector2D &value) {
     73void TrajectoryGenerator2DCircle::SetCenterSpeed(const Vector2Df &value) {
    7474  pimpl_->vel_off = value;
    7575}
  • trunk/lib/FlairFilter/src/TrajectoryGenerator2DCircle.h

    r15 r167  
    1515
    1616#include <IODevice.h>
     17#include <Vector2D.h>
    1718
    1819namespace flair {
    1920namespace core {
    2021class cvmatrix;
    21 class Vector2D;
    2222}
    2323namespace gui {
     
    7272  * \param nb_lap number of laps, -1 for infinite
    7373  */
    74   void StartTraj(const core::Vector2D &start_pos, float nb_lap = -1);
     74  void StartTraj(const core::Vector2Df &start_pos, float nb_lap = -1);
    7575
    7676  /*!
     
    9393  * \param value center position
    9494  */
    95   void SetCenter(const core::Vector2D &value);
     95  void SetCenter(const core::Vector2Df &value);
    9696
    9797  /*!
     
    100100  * \param value center speed
    101101  */
    102   void SetCenterSpeed(const core::Vector2D &value);
     102  void SetCenterSpeed(const core::Vector2Df &value);
    103103
    104104  /*!
     
    117117  * \param point returned position
    118118  */
    119   void GetPosition(core::Vector2D &point) const;
     119  void GetPosition(core::Vector2Df &point) const;
    120120
    121121  /*!
     
    124124  * \param point returned speed
    125125  */
    126   void GetSpeed(core::Vector2D &point) const;
     126  void GetSpeed(core::Vector2Df &point) const;
    127127
    128128  /*!
  • trunk/lib/FlairFilter/src/TrajectoryGenerator2DCircle_impl.cpp

    r148 r167  
    6464}
    6565
    66 void TrajectoryGenerator2DCircle_impl::StartTraj(const Vector2D &start_pos,
     66void TrajectoryGenerator2DCircle_impl::StartTraj(const Vector2Df &start_pos,
    6767                                                 float nb_lap) {
    6868  is_running = true;
     
    8989  float A = acceleration->Value();
    9090  float R = rayon->Value();
    91   Vector2D v;
     91  Vector2Df v;
    9292
    9393  if (V < 0)
  • trunk/lib/FlairFilter/src/unexported/TrajectoryGenerator2DCircle_impl.h

    r15 r167  
    4343  ~TrajectoryGenerator2DCircle_impl();
    4444  void Update(flair::core::Time time);
    45   void StartTraj(const flair::core::Vector2D &start_pos, float nb_lap);
     45  void StartTraj(const flair::core::Vector2Df &start_pos, float nb_lap);
    4646  void FinishTraj(void);
    4747  bool is_running;
    4848  flair::core::cvmatrix *output;
    49   flair::core::Vector2D pos_off, vel_off;
     49  flair::core::Vector2Df pos_off, vel_off;
    5050
    5151private:
     
    5353  float CurrentTime, FinishTime;
    5454  bool first_update, is_finishing;
    55   flair::core::Vector2D pos;
     55  flair::core::Vector2Df pos;
    5656  float angle_off;
    5757  flair::gui::DoubleSpinBox *T, *veloctity, *acceleration, *rayon;
  • trunk/lib/FlairMeta/src/MetaVrpnObject.cpp

    r148 r167  
    2828#include <TabWidget.h>
    2929#include <cvmatrix.h>
    30 #include <Vector3D.h>
    3130
    3231using std::string;
     
    5554    desc->SetElementName(i, 0, Output()->Name(i, 0));
    5655  }
    57   cvmatrix *prev_value = new cvmatrix(this, desc, elementDataType, name);
     56  cvmatrix *prev_value = new cvmatrix(this, desc, floatType, name);
    5857  delete desc;
    5958
     
    6665    desc->SetElementName(i, 0, "d" + Output()->Name(i, 0));
    6766  }
    68   prev_value = new cvmatrix(this, desc, elementDataType, name);
     67  prev_value = new cvmatrix(this, desc, floatType, name);
    6968  delete desc;
    7069
     
    9594DataPlot2D *MetaVrpnObject::XyPlot(void) const { return xy_plot; }
    9695
    97 void MetaVrpnObject::GetSpeed(Vector3D &speed) const {
     96void MetaVrpnObject::GetSpeed(Vector3Df &speed) const {
    9897  speed.x = euler->Output(4, 0);
    9998  speed.y = euler->Output(5, 0);
  • trunk/lib/FlairMeta/src/MetaVrpnObject.h

    r122 r167  
    1515
    1616#include <VrpnObject.h>
    17 #include "io_data.h"
     17#include <io_data.h>
     18#include <Vector3D.h>
    1819
    1920namespace flair {
    20         namespace core {
    21                 class Vector3D;
    22                 class FloatType;
    23         }
    2421        namespace gui {
    2522                class DataPlot1D;
     
    5148  gui::DataPlot1D *VzPlot(void) const; // 1,2
    5249  gui::DataPlot2D *XyPlot(void) const;
    53   void GetSpeed(core::Vector3D &speed) const;
     50  void GetSpeed(core::Vector3Df &speed) const;
    5451
    5552private:
     
    6057  gui::DataPlot1D *vx_opti_plot, *vy_opti_plot, *vz_opti_plot;
    6158  gui::Tab *plot_tab;
    62   core::FloatType elementDataType;
    6359};
    6460} // end namespace meta
  • trunk/lib/FlairMeta/src/UavStateMachine.cpp

    r164 r167  
    132132}
    133133
    134 const Vector3D &UavStateMachine::GetCurrentAngularSpeed(void) const {
     134const Vector3Df &UavStateMachine::GetCurrentAngularSpeed(void) const {
    135135  return currentAngularSpeed;
    136136}
     
    423423    const AhrsData *refOrientation = ComputeReferenceOrientation();
    424424    Quaternion refQuaternion;
    425     Vector3D refAngularRates;
     425    Vector3Df refAngularRates;
    426426    refOrientation->GetQuaternionAndAngularRates(refQuaternion,
    427427                                                 refAngularRates);
  • trunk/lib/FlairMeta/src/UavStateMachine.h

    r165 r167  
    107107  const core::Quaternion &GetCurrentQuaternion(void) const;
    108108
    109   const core::Vector3D &GetCurrentAngularSpeed(void) const;
     109  const core::Vector3Df &GetCurrentAngularSpeed(void) const;
    110110
    111111        void Land(void);
     
    267267
    268268  core::Quaternion currentQuaternion;
    269   core::Vector3D currentAngularSpeed;
     269  core::Vector3Df currentAngularSpeed;
    270270
    271271  const core::AhrsData *ComputeReferenceOrientation(void);
  • trunk/lib/FlairSensorActuator/src/Gx3_25_imu_impl.cpp

    r157 r167  
    130130      eulerAngles.yaw = Dequeue(&buf);
    131131
    132       Vector3D filteredAngRates;
     132      Vector3Df filteredAngRates;
    133133      filteredAngRates.x = Dequeue(&buf);
    134134      filteredAngRates.y = Dequeue(&buf);
     
    143143      GetData(response, sizeof(response), &imuTime);
    144144
    145       Vector3D rawAcc;
     145      Vector3Df rawAcc;
    146146      rawAcc.x = 9.80665 * Dequeue(&buf);
    147147      rawAcc.y = 9.80665 * Dequeue(&buf);
    148148      rawAcc.z = 9.80665 * Dequeue(&buf);
    149149
    150       Vector3D filteredAngRates;
     150      Vector3Df filteredAngRates;
    151151      filteredAngRates.x = Dequeue(&buf);
    152152      filteredAngRates.y = Dequeue(&buf);
     
    178178      quaternion.q3 = Dequeue(&buf);
    179179
    180       Vector3D filteredAngRates;
     180      Vector3Df filteredAngRates;
    181181      filteredAngRates.x = 0;
    182182      filteredAngRates.y = 0;
  • trunk/lib/FlairSensorActuator/src/Imu.cpp

    r137 r167  
    6969    return;
    7070  }
    71   Vector3D rawAcc, rawMag, rawGyr;
     71  Vector3Df rawAcc, rawMag, rawGyr;
    7272  imuData->GetRawAccMagAndGyr(rawAcc, rawMag, rawGyr);
    7373  rotation->ComputeRotation(rawAcc);
  • trunk/lib/FlairSensorActuator/src/NmeaGps.cpp

    r137 r167  
    173173void NmeaGps::SetRef(void) { takeRef = true; }
    174174
    175 void NmeaGps::GetEnu(Vector3D *point) {
     175void NmeaGps::GetEnu(Vector3Df *point) {
    176176  gpsData->GetMutex();
    177177  gpsData->GetEnu(point->x,point->y,point->z);
  • trunk/lib/FlairSensorActuator/src/NmeaGps.h

    r137 r167  
    1515
    1616#include <IODevice.h>
     17#include <Vector3D.h>
    1718#include <nmea/nmea.h>
    1819
     
    2122    class FrameworkManager;
    2223    class GeoCoordinate;
    23     class Vector3D;
    2424    class GpsData;
    2525  }
     
    168168  * \param point to store position
    169169  */
    170   void GetEnu(core::Vector3D *point);
     170  void GetEnu(core::Vector3Df *point);
    171171
    172172protected:
  • trunk/lib/FlairSensorActuator/src/SimuImu.cpp

    r158 r167  
    107107    ahrsData->SetQuaternionAndAngularRates(
    108108        Quaternion(state.q0, state.q1, state.q2, state.q3),
    109         Vector3D(state.wx, state.wy, state.wz));
     109        Vector3Df(state.wx, state.wy, state.wz));
    110110
    111111    imuData->SetDataTime(GetTime());
  • trunk/lib/FlairSensorActuator/src/VrpnClient_impl.cpp

    r140 r167  
    104104}
    105105
    106 void VrpnClient_impl::ComputeRotations(Vector3D &point) {
     106void VrpnClient_impl::ComputeRotations(Vector3Df &point) {
    107107  rotation_1->ComputeRotation(point);
    108108  rotation_2->ComputeRotation(point);
  • trunk/lib/FlairSensorActuator/src/VrpnObject.cpp

    r157 r167  
    7777}
    7878
    79 void VrpnObject::GetPosition(Vector3D &point) const {
     79void VrpnObject::GetPosition(Vector3Df &point) const {
    8080  pimpl_->GetPosition(point);
    8181}
  • trunk/lib/FlairSensorActuator/src/VrpnObject.h

    r140 r167  
    1616
    1717#include <IODevice.h>
     18#include <Vector3D.h>
    1819#include <stdint.h>
    1920
     
    2122        namespace core {
    2223                class cvmatrix;
    23                 class Vector3D;
    2424                class Quaternion;
    2525        }
     
    110110  * \param point output datas
    111111  */
    112   void GetPosition(core::Vector3D &point) const;
     112  void GetPosition(core::Vector3Df &point) const;
    113113
    114114  /*!
  • trunk/lib/FlairSensorActuator/src/VrpnObject_impl.cpp

    r148 r167  
    129129}
    130130
    131 void VrpnObject_impl::GetPosition(Vector3D &point) {
     131void VrpnObject_impl::GetPosition(Vector3Df &point) {
    132132  output->GetMutex();
    133133  point.x = output->ValueNoMutex(4, 0);
     
    163163  // flair::core::Quaternion
    164164        Quaternion quaternion(t.quat[3],t.quat[0],t.quat[1],t.quat[2]);
    165   Vector3D pos((float)t.pos[0], (float)t.pos[1], (float)t.pos[2]);
     165  Vector3Df pos((float)t.pos[0], (float)t.pos[1], (float)t.pos[2]);
    166166
    167167  // on effectue les rotation
  • trunk/lib/FlairSensorActuator/src/unexported/VrpnClient_impl.h

    r140 r167  
    2121#include <string>
    2222#include <vector>
     23#include "Vector3D.h"
    2324
    2425namespace flair {
    2526namespace core {
    2627class OneAxisRotation;
    27 class Vector3D;
    2828class Quaternion;
    2929class Mutex;
     
    5454  void AddTrackable(VrpnObject_impl *obj, uint8_t id);  // xbee
    5555  void RemoveTrackable(VrpnObject_impl *obj);           // normal+xbee
    56   void ComputeRotations(flair::core::Vector3D &point);
     56  void ComputeRotations(flair::core::Vector3Df &point);
    5757  void ComputeRotations(flair::core::Quaternion &quat);
    5858  bool UseXbee(void);
  • trunk/lib/FlairSensorActuator/src/unexported/VrpnObject_impl.h

    r140 r167  
    2424#include <vrpn_Tracker.h>
    2525#include "Quaternion.h"
     26#include "Vector3D.h"
    2627
    2728namespace flair {
    2829        namespace core {
    2930                class cvmatrix;
    30                 class Vector3D;
    3131        }
    3232        namespace gui {
     
    5151
    5252  void GetQuaternion(flair::core::Quaternion &quaternion);
    53   void GetPosition(flair::core::Vector3D &point);
     53  void GetPosition(flair::core::Vector3Df &point);
    5454  bool IsTracked(unsigned int timeout_ms);
    5555
  • trunk/lib/FlairSimulator/src/FixedCamera.cpp

    r120 r167  
    3535namespace simulator {
    3636
    37 FixedCamera::FixedCamera(std::string name,core::Vector3D position,core::Vector3D lookat,float inRotateSpeed,float inZoomSpeed):VisualizationCamera(name)  {
     37FixedCamera::FixedCamera(std::string name,core::Vector3Df position,core::Vector3Df lookat,float inRotateSpeed,float inZoomSpeed):VisualizationCamera(name)  {
    3838  Rotating = false;
    3939  rotateSpeed=inRotateSpeed;
     
    6262
    6363      //normal between target and up vector
    64       cameraAxeY=target.crossProduct(irr::core::vector3df(0,0,1));
     64      cameraAxeY=target.crossProduct(vector3df(0,0,1));
    6565      cameraAxeY.normalize();
    6666
     
    8181
    8282      //check angle
    83       irr::core::vector3df newTarget(q3.X,q3.Y,q3.Z);
    84       float angle=acos(newTarget.dotProduct(irr::core::vector3df(0,0,1))/newTarget.getLength());
    85       irr::core::vector3df cross = newTarget.crossProduct(irr::core::vector3df(0,0,1));
     83      vector3df newTarget(q3.X,q3.Y,q3.Z);
     84      float angle=acos(newTarget.dotProduct(vector3df(0,0,1))/newTarget.getLength());
     85      vector3df cross = newTarget.crossProduct(vector3df(0,0,1));
    8686      if (cross.dotProduct(cameraAxeY) > 0) {
    8787        newTarget += camera->getAbsolutePosition();
  • trunk/lib/FlairSimulator/src/FixedCamera.h

    r120 r167  
    2626class FixedCamera : public VisualizationCamera {
    2727public:
    28   FixedCamera(std::string name,core::Vector3D position,core::Vector3D lookat=core::Vector3D(0,0,0),float rotateSpeed = -3.0f, float zoomSpeed = .05f);
     28  FixedCamera(std::string name,core::Vector3Df position,core::Vector3Df lookat=core::Vector3Df(0,0,0),float rotateSpeed = -3.0f, float zoomSpeed = .05f);
    2929  ~FixedCamera();
    3030
  • trunk/lib/FlairSimulator/src/Gui.cpp

    r158 r167  
    109109}
    110110
    111 vector3df ToIrrlichtCoordinates(Vector3D vect) {
     111template<typename T> vector3df ToIrrlichtCoordinates(Vector3D<T> vect) {
    112112  return ToIrrlichtScale(1) * vector3df(vect.x, vect.y, -vect.z);
    113113}
    114114
    115 Vector3D ToSimulatorCoordinates(vector3df vect) {
    116   return ToSimulatorScale(1) * Vector3D(vect.X, vect.Y, -vect.Z);
     115Vector3Df ToSimulatorCoordinates(vector3df vect) {
     116  return ToSimulatorScale(1) * Vector3Df(vect.X, vect.Y, -vect.Z);
    117117}
    118118
     
    132132  return Quaternion(quat.q0, -quat.q1, -quat.q2, quat.q3);
    133133}
     134
     135
     136template irr::core::vector3df ToIrrlichtCoordinates(core::Vector3D<double>);
     137template irr::core::vector3df ToIrrlichtCoordinates(core::Vector3D<float>);
    134138
    135139Gui::Gui(std::string name, int app_width,
  • trunk/lib/FlairSimulator/src/Gui.h

    r158 r167  
    1919
    2020#include <Object.h>
     21#include <Vector3D.h>
    2122#include <EDriverTypes.h>
    2223#include <vector3d.h>
     
    3637namespace core {
    3738class Object;
    38 class Vector3D;
    3939class Euler;
    4040class Quaternion;
     
    125125* \return vector in irrlicht coordinates
    126126*/
    127 irr::core::vector3df ToIrrlichtCoordinates(core::Vector3D vect);
     127template<typename T>  irr::core::vector3df ToIrrlichtCoordinates(core::Vector3D<T> vect);
    128128
    129129/*!
     
    136136* \return vector in simulator coordinates
    137137*/
    138 core::Vector3D ToSimulatorCoordinates(irr::core::vector3df vect);
     138core::Vector3Df ToSimulatorCoordinates(irr::core::vector3df vect);
    139139
    140140/*!
  • trunk/lib/FlairSimulator/src/Man.cpp

    r158 r167  
    7373  state[0].Quat.Normalize();
    7474
    75   Vector3D dir = state[0].Vel;
     75  Vector3D<double> dir = state[0].Vel;
    7676  dir.Rotate(state[0].Quat);
    7777  state[0].Pos = state[-1].Pos + dT() * dir;
  • trunk/lib/FlairSimulator/src/Model.cpp

    r158 r167  
    6969TabWidget *Model::GetTabWidget(void) const { return pimpl_->tabwidget; }
    7070
    71 float Model::dT(void) const { return pimpl_->dT->Value(); }
     71double Model::dT(void) const { return pimpl_->dT->Value(); }
    7272
    7373int Model::GetId(void) const {
  • trunk/lib/FlairSimulator/src/Model.h

    r158 r167  
    6969  typedef struct simu_state {
    7070    core::Quaternion Quat;
    71     core::Vector3D W;
    72     core::Vector3D Pos;
    73     core::Vector3D Vel;
     71    core::Vector3Df W;
     72    core::Vector3D<double> Pos;
     73    core::Vector3D<double> Vel;
    7474  } simu_state_t;
    7575
     
    9696protected:
    9797  DiscreteTimeVariable<simu_state_t, 3> state;
    98   float dT(void) const;
     98  double dT(void) const;
    9999  virtual void CalcModel(void) = 0;
    100100#ifdef GL
  • trunk/lib/FlairSimulator/src/Model_impl.cpp

    r163 r167  
    160160  states_mutex->GetMutex();
    161161  Quaternion quat = getSimulator()->ToVRPNReference(self->state[0].Quat);
    162   Vector3D position = getSimulator()->ToVRPNReference(self->state[0].Pos);
     162  Vector3D<double> position = getSimulator()->ToVRPNReference(self->state[0].Pos);
    163163  states_mutex->ReleaseMutex();
    164164
  • trunk/lib/FlairSimulator/src/Parser.cpp

    r158 r167  
    210210}
    211211
    212 Vector3D Parser::getMeshVector3D(xmlNode *mesh_node, xmlChar *param) {
     212Vector3Df Parser::getMeshVector3D(xmlNode *mesh_node, xmlChar *param) {
    213213  xmlNode *cur_node = NULL;
    214214  for (cur_node = mesh_node; cur_node; cur_node = cur_node->next) {
    215215    if (xmlStrEqual(cur_node->name, param)) {
    216       return Vector3D(atof((char *)xmlGetProp(cur_node, (xmlChar *)"x")),
     216      return Vector3Df(atof((char *)xmlGetProp(cur_node, (xmlChar *)"x")),
    217217                       atof((char *)xmlGetProp(cur_node, (xmlChar *)"y")),
    218218                       atof((char *)xmlGetProp(cur_node, (xmlChar *)"z")));
    219219    }
    220220  }
    221   return Vector3D(0, 0, 0);
     221  return Vector3Df(0, 0, 0);
    222222}
    223223
  • trunk/lib/FlairSimulator/src/Parser.h

    r158 r167  
    1919
    2020#include <Gui.h>
     21#include <Vector3D.h>
    2122#include <libxml/parser.h>
    2223#include <libxml/tree.h>
    2324#include <SColor.h>
    24 
    25 namespace flair {
    26   namespace core {
    27     class Vector3D;
    28   }
    29 }
    3025
    3126namespace flair {
     
    5348  irr::core::vector3df getSceneVect(xmlNode *mesh_node, xmlChar *param,
    5449                                    bool isScale = false);
    55   core::Vector3D getMeshVector3D(xmlNode *mesh_node, xmlChar *param);
     50  core::Vector3Df getMeshVector3D(xmlNode *mesh_node, xmlChar *param);
    5651};
    5752}
  • trunk/lib/FlairSimulator/src/SimuUsGL.cpp

    r158 r167  
    4343  position = new Vector3DSpinBox(setup_tab->NewRow(), "position", -2, 2, .01);
    4444  direction = new Vector3DSpinBox(setup_tab->NewRow(), "direction", -2, 2, .01);
    45   range = new DoubleSpinBox(setup_tab->NewRow(), "range:", 0, 6, 1);
     45  range = new DoubleSpinBox(setup_tab->NewRow(), "range:", 0, 1000, 1,0,6.);
    4646}
    4747
  • trunk/lib/FlairSimulator/src/Simulator.cpp

    r15 r167  
    5656}
    5757
    58 Vector3D Simulator::ToVRPNReference(Vector3D point_in) {
     58Vector3D<double> Simulator::ToVRPNReference(Vector3D<double> point_in) {
    5959  Quaternion yaw_rot_quat;
    6060  Euler yaw_rot_euler(
  • trunk/lib/FlairSimulator/src/Simulator.h

    r158 r167  
    1919
    2020#include <FrameworkManager.h>
     21#include <Vector3D.h>
    2122#include <stdint.h>
    2223
     
    2728namespace core {
    2829class Quaternion;
    29 class Vector3D;
    3030}
    3131}
     
    5353  // coordinate, around z axis
    5454  core::Quaternion ToVRPNReference(core::Quaternion quat_in);
    55   core::Vector3D ToVRPNReference(core::Vector3D point_in);
     55  core::Vector3D<double> ToVRPNReference(core::Vector3D<double> point_in);
    5656
    5757private:
  • trunk/lib/FlairSimulator/src/X4.cpp

    r158 r167  
    282282  u_thrust = k_mot->Value() * (fl_speed * fl_speed + fr_speed * fr_speed +
    283283                               rl_speed * rl_speed + rr_speed * rr_speed);
    284   Vector3D vect(0, 0, -u_thrust);
     284  Vector3D<double> vect(0, 0, -u_thrust);
    285285  vect.Rotate(state[0].Quat);
    286286
     
    291291      ** ===================================================================
    292292      */
     293     
    293294  state[0].Pos.x =
    294295      (dT() * dT() / m->Value()) *
    295           (vect.x -
    296            f_air_lat->Value() * (state[-1].Pos.x - state[-2].Pos.x) / dT()) +
     296          (vect.x - f_air_lat->Value() * (state[-1].Pos.x - state[-2].Pos.x) / dT()) +
    297297      2 * state[-1].Pos.x - state[-2].Pos.x;
    298298  state[0].Vel.x = (state[0].Pos.x - state[-1].Pos.x) / dT();
    299 
     299 
    300300  /*
    301301  ** ===================================================================
  • trunk/lib/FlairSimulator/src/X8.cpp

    r158 r167  
    339339       sigma->Value() * trr_speed * trr_speed + bfl_speed * bfl_speed +
    340340       bfr_speed * bfr_speed + brl_speed * brl_speed + brr_speed * brr_speed);
    341   Vector3D vect(0, 0, -u_thrust);
     341  Vector3D<double> vect(0, 0, -u_thrust);
    342342  vect.Rotate(state[0].Quat);
    343343
  • trunk/lib/FlairSimulator/src/unexported/Model_impl.h

    r158 r167  
    120120  flair::core::Mutex *collision_mutex;
    121121  bool collision_occured;
    122   flair::core::Vector3D collision_point;
     122  flair::core::Vector3D<double> collision_point;
    123123#endif
    124124};
  • trunk/lib/FlairVisionFilter/src/OpticalFlow.cpp

    r157 r167  
    128128    //apply rotation
    129129    for(i=0;i<count;i++) {
    130         Vector3D tmp;
     130        Vector3Df tmp;
    131131        tmp.x=pointsA[i].x;
    132132        tmp.y=pointsA[i].y;
Note: See TracChangeset for help on using the changeset viewer.