source: flair-src/trunk/lib/FlairCore/src/Quaternion.h@ 2

Last change on this file since 2 was 2, checked in by Sanahuja Guillaume, 6 years ago

flaircore

File size: 4.8 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
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
15namespace flair { namespace core {
16 class Euler;
17 class Vector3D;
18 class RotationMatrix;
19
20 /*! \class Quaternion
21 *
22 * \brief Class defining a quaternion
23 */
24 class Quaternion {
25 public:
26 /*!
27 * \brief Constructor
28 *
29 * Construct a quaternion using specified values.
30 *
31 * \param q0, scalar part
32 * \param q1
33 * \param q2
34 * \param q3
35 */
36 Quaternion(float q0=1,float q1=0,float q2=0,float q3=0);
37
38 /*!
39 * \brief Destructor
40 *
41 */
42 ~Quaternion();
43
44 /*!
45 * \brief Norm
46 *
47 * \return norm
48 */
49 float GetNorm(void) const;
50
51 /*!
52 * \brief Normalize
53 */
54 void Normalize(void);
55
56 /*!
57 * \brief Logarithm
58 *
59 * This method also Normalize the quaternion.
60 *
61 * \param logarithm output logarithm
62 */
63 void GetLogarithm(Vector3D &logarithm);
64
65 /*!
66 * \brief Logarithm
67 *
68 * This method also Normalize the quaternion.
69 *
70 * \return output logarithm
71 */
72 Vector3D GetLogarithm(void);
73
74 /*!
75 * \brief Conjugate
76 */
77 void Conjugate(void);
78
79 /*!
80 * \brief Conjugate
81 *
82 * \return Conjugate
83 */
84 Quaternion GetConjugate(void);
85
86 /*!
87 * \brief Derivative
88 *
89 * \param w angular speed
90 *
91 * \return derivative
92 */
93 Quaternion GetDerivative(const Vector3D &angularSpeed) const;
94
95 /*!
96 * \brief Derivate
97 *
98 * \param w rotationonal speed
99 */
100 void Derivate(const Vector3D &angularSpeed);
101
102 /*!
103 * \brief Convert to euler angles
104 *
105 * \param euler output euler angles
106 */
107 void ToEuler(Euler &euler) const;
108
109 /*!
110 * \brief Convert to euler angles
111 *
112 * \return euler angles
113 */
114 Euler ToEuler(void) const;
115
116 /*!
117 * \brief Convert to rotation matrix
118 *
119 * \param m output matrix
120 */
121 void ToRotationMatrix(RotationMatrix &matrix) const;
122
123 /*!
124 * \brief q0
125 */
126 float q0;
127
128 /*!
129 * \brief q1
130 */
131 float q1;
132
133 /*!
134 * \brief q2
135 */
136 float q2;
137
138 /*!
139 * \brief q3
140 */
141 float q3;
142
143 Quaternion& operator+=(const Quaternion& quaternion);
144 Quaternion& operator-=(const Quaternion& quaternion);
145 Quaternion& operator=(const Quaternion& quaternion);
146 };
147
148 /*! Add
149 *
150 * \brief Add
151 *
152 * \param quaterniontA quaternion
153 * \param quaterniontB quaternion
154 *
155 * \return quaterniontA+quaterniontB
156 */
157 Quaternion operator + (Quaternion const &quaterniontA,Quaternion const &quaterniontB);
158
159 /*! Substract
160 *
161 * \brief Substract
162 *
163 * \param quaterniontA quaternion
164 * \param quaterniontB quaternion
165 *
166 * \return quaterniontA-quaterniontB
167 */
168 Quaternion operator - (Quaternion const &quaternionA,Quaternion const &quaterniontB);
169
170 /*! Minus
171 *
172 * \brief Minus
173 *
174 * \param quaternion quaternion
175 *
176 * \return -quaternion
177 */
178 Quaternion operator-(const Quaternion &quaternion);
179
180 /*! Multiply
181 *
182 * \brief Multiply
183 *
184 * \param quaterniontA quaternion
185 * \param quaterniontB quaternion
186 *
187 * \return quaterniontA*quaterniontB
188 */
189 Quaternion operator * (Quaternion const &quaternionA,Quaternion const &quaterniontB);
190
191 /*! Multiply
192 *
193 * \brief Multiply
194 *
195 * \param coeff coefficient
196 * \param quat quaternion
197 *
198 * \return coeff*quat
199 */
200 Quaternion operator * (float coeff,Quaternion const &quaternion);
201
202 /*! Multiply
203 *
204 * \brief Multiply
205 *
206 * \param quat quaternion
207 * \param coeff coefficient
208 *
209 * \return coeff*quat
210 */
211 Quaternion operator * (Quaternion const &quaternion,float coeff);
212
213} // end namespace core
214} // end namespace flair
215
216#endif // QUATERNION_H
Note: See TracBrowser for help on using the repository browser.