[2]  1  // %flair:license{


[15]  2  // This file is part of the Flair framework distributed under the


 3  // CECILLC License, Version 1.0.


[2]  4  // %flair:license}


 5  /*!


 6  * \file Quaternion.h


 7  * \brief Class defining a quaternion


 8  * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253


 9  * \date 2016/02/03


 10  * \version 4.0


 11  */


 12  #ifndef QUATERNION_H


 13  #define QUATERNION_H


 14 


[15]  15  namespace flair {


 16  namespace core {


 17  class Euler;


 18  class Vector3D;


 19  class RotationMatrix;


[2]  20 


[15]  21  /*! \class Quaternion


 22  *


 23  * \brief Class defining a quaternion


 24  */


 25  class Quaternion {


 26  public:


 27  /*!


 28  * \brief Constructor


 29  *


 30  * Construct a quaternion using specified values.


 31  *


 32  * \param q0, scalar part


 33  * \param q1


 34  * \param q2


 35  * \param q3


 36  */


 37  Quaternion(float q0 = 1, float q1 = 0, float q2 = 0, float q3 = 0);


[2]  38 


[15]  39  /*!


 40  * \brief Destructor


 41  *


 42  */


 43  ~Quaternion();


[2]  44 


[15]  45  /*!


 46  * \brief Norm


 47  *


 48  * \return norm


 49  */


 50  float GetNorm(void) const;


[2]  51 


[15]  52  /*!


 53  * \brief Normalize


 54  */


 55  void Normalize(void);


[2]  56 


[15]  57  /*!


 58  * \brief Logarithm


 59  *


 60  * This method also Normalize the quaternion.


 61  *


 62  * \param logarithm output logarithm


 63  */


 64  void GetLogarithm(Vector3D &logarithm);


[2]  65 


[15]  66  /*!


 67  * \brief Logarithm


 68  *


 69  * This method also Normalize the quaternion.


 70  *


 71  * \return output logarithm


 72  */


 73  Vector3D GetLogarithm(void);


[2]  74 


[15]  75  /*!


 76  * \brief Conjugate


 77  */


 78  void Conjugate(void);


[2]  79 


[15]  80  /*!


 81  * \brief Conjugate


 82  *


 83  * \return Conjugate


 84  */


 85  Quaternion GetConjugate(void);


[2]  86 


[15]  87  /*!


 88  * \brief Derivative


 89  *


 90  * \param w angular speed


 91  *


 92  * \return derivative


 93  */


 94  Quaternion GetDerivative(const Vector3D &angularSpeed) const;


[2]  95 


[15]  96  /*!


 97  * \brief Derivate


 98  *


 99  * \param w rotationonal speed


 100  */


 101  void Derivate(const Vector3D &angularSpeed);


[2]  102 


[15]  103  /*!


 104  * \brief Convert to euler angles


 105  *


 106  * \param euler output euler angles


 107  */


 108  void ToEuler(Euler &euler) const;


[2]  109 


[15]  110  /*!


 111  * \brief Convert to euler angles


 112  *


 113  * \return euler angles


 114  */


 115  Euler ToEuler(void) const;


[2]  116 


[15]  117  /*!


 118  * \brief Convert to rotation matrix


 119  *


 120  * \param m output matrix


 121  */


 122  void ToRotationMatrix(RotationMatrix &matrix) const;


[2]  123 


[15]  124  /*!


 125  * \brief q0


 126  */


 127  float q0;


[2]  128 


[15]  129  /*!


 130  * \brief q1


 131  */


 132  float q1;


[2]  133 


[15]  134  /*!


 135  * \brief q2


 136  */


 137  float q2;


[2]  138 


[15]  139  /*!


 140  * \brief q3


 141  */


 142  float q3;


[2]  143 


[15]  144  Quaternion &operator+=(const Quaternion &quaternion);


 145  Quaternion &operator=(const Quaternion &quaternion);


 146  Quaternion &operator=(const Quaternion &quaternion);


 147  };


[2]  148 


[15]  149  /*! Add


 150  *


 151  * \brief Add


 152  *


 153  * \param quaterniontA quaternion


 154  * \param quaterniontB quaternion


 155  *


 156  * \return quaterniontA+quaterniontB


 157  */


 158  Quaternion operator+(Quaternion const &quaterniontA,


 159  Quaternion const &quaterniontB);


[2]  160 


[15]  161  /*! Substract


 162  *


 163  * \brief Substract


 164  *


 165  * \param quaterniontA quaternion


 166  * \param quaterniontB quaternion


 167  *


 168  * \return quaterniontAquaterniontB


 169  */


 170  Quaternion operator(Quaternion const &quaternionA,


 171  Quaternion const &quaterniontB);


[2]  172 


[15]  173  /*! Minus


 174  *


 175  * \brief Minus


 176  *


 177  * \param quaternion quaternion


 178  *


 179  * \return quaternion


 180  */


 181  Quaternion operator(const Quaternion &quaternion);


[2]  182 


[15]  183  /*! Multiply


 184  *


 185  * \brief Multiply


 186  *


 187  * \param quaterniontA quaternion


 188  * \param quaterniontB quaternion


 189  *


 190  * \return quaterniontA*quaterniontB


 191  */


 192  Quaternion operator*(Quaternion const &quaternionA,


 193  Quaternion const &quaterniontB);


[2]  194 


[15]  195  /*! Multiply


 196  *


 197  * \brief Multiply


 198  *


 199  * \param coeff coefficient


 200  * \param quat quaternion


 201  *


 202  * \return coeff*quat


 203  */


 204  Quaternion operator*(float coeff, Quaternion const &quaternion);


[2]  205 


[15]  206  /*! Multiply


 207  *


 208  * \brief Multiply


 209  *


 210  * \param quat quaternion


 211  * \param coeff coefficient


 212  *


 213  * \return coeff*quat


 214  */


 215  Quaternion operator*(Quaternion const &quaternion, float coeff);


[2]  216 


 217  } // end namespace core


 218  } // end namespace flair


 219 


 220  #endif // QUATERNION_H

