2 * Class that represents a Quaternion
3 * Author: Alfredo Morales Pinzón
4 * Date: October 7, 2014
7 #ifndef __Quaternion_h__
8 #define __Quaternion_h__
18 #include <Airways/MathLib/TempAirwaysAppli_MathLib_Export.h>
24 //------------------------------------------------------------------------------
25 // Class that represents a Quaterion with all its operations
26 //------------------------------------------------------------------------------
27 class TempAirwaysAppli_MathLib_EXPORT Quaternion
31 //------------------------------------------------------------
33 //------------------------------------------------------------
41 * Class builder using two vectors
42 * @param v1 is the first vector
43 * @param v2 is the second vector
45 Quaternion(Vec3 v1, Vec3 v2);
48 * Class builder using theta and w vector
49 * @param nTheta is the theta angle
50 * @param nW is the w vector
52 Quaternion(float nTheta, Vec3 nW);
55 * Class builder using r and im
56 * @param nR in the real part of the quaternion
57 * @param nI, nJ and nK are the imaginary parts of the quaternion
59 Quaternion(float nR, float nI, float nJ, float nK);
61 //------------------------------------------------------------
63 //------------------------------------------------------------
67 //------------------------------------------------------------
69 //------------------------------------------------------------
72 * Method that returns the real (r) component
73 * @return the r component
78 * Method that returns the i component
79 * @return the i component
84 * Method that returns the j component
85 * @return the j component
90 * Method that returns the k component
91 * @return the k component
96 * Method that returns the w vector
97 * @return the w vector
102 * Method that returns the conjugate of the quaternion
103 * @return the conjugate of the quaternion
105 Quaternion conjugate( );
108 * Method that returns a vector transformed by the quaternion
109 * @param vector to be rotated
110 * @return the transformed vector
112 Vec3 rotateVector(Vec3 vector);
114 //------------------------------------------------------------
116 //------------------------------------------------------------
119 * Definition of operator *
120 * @param is the quaternion to be multiplied with
121 * @return the multiplication quaternion
123 Quaternion operator*(Quaternion q);
126 * Definition of operator []
127 * @param Position of the quanternion to be returned. Position 0 corresponds
128 * to the real component and 1, 2, and 3 to the complex components.
129 * @param The value on the specified position is returned.
132 const float& operator[](unsigned int i) const;
137 friend std::ostream& operator<<(std::ostream& os, const Quaternion& coord);
142 //------------------------------------------------------------
144 //------------------------------------------------------------
147 //------------------------------------------------------------
149 //------------------------------------------------------------
152 * Real part of the quaternion
157 * Angle between vectors
167 * Vector the quaternion
173 //------------------------------------------------------------------------------