/** * Class that represents a Quaternion * Author: Alfredo Morales Pinzón * Date: October 7, 2014 */ #ifndef __Quaternion_h__ #define __Quaternion_h__ //----------------- // C++ //----------------- #include //----------------- // OWN //----------------- #include #include "vec3.h" // Namespaces using namespace std; //------------------------------------------------------------------------------ // Class that represents a Quaterion with all its operations //------------------------------------------------------------------------------ class TempAirwaysAppli_MathLib_EXPORT Quaternion { public: //------------------------------------------------------------ //Builder //------------------------------------------------------------ /* * Class builder */ Quaternion( ); /* * Class builder using two vectors * @param v1 is the first vector * @param v2 is the second vector */ Quaternion(Vec3 v1, Vec3 v2); /* * Class builder using theta and w vector * @param nTheta is the theta angle * @param nW is the w vector */ Quaternion(float nTheta, Vec3 nW); /* * Class builder using r and im * @param nR in the real part of the quaternion * @param nI, nJ and nK are the imaginary parts of the quaternion */ Quaternion(float nR, float nI, float nJ, float nK); //------------------------------------------------------------ //Destructor //------------------------------------------------------------ ~Quaternion(); //------------------------------------------------------------ //Public methods //------------------------------------------------------------ /** * Method that returns the real (r) component * @return the r component */ float getR(); /** * Method that returns the i component * @return the i component */ float getI(); /** * Method that returns the j component * @return the j component */ float getJ(); /** * Method that returns the k component * @return the k component */ float getK(); /** * Method that returns the w vector * @return the w vector */ Vec3 getW(); /** * Method that returns the conjugate of the quaternion * @return the conjugate of the quaternion */ Quaternion conjugate( ); /** * Method that returns a vector transformed by the quaternion * @param vector to be rotated * @return the transformed vector */ Vec3 rotateVector(Vec3 vector); //------------------------------------------------------------ //Operators //------------------------------------------------------------ /* * Definition of operator * * @param is the quaternion to be multiplied with * @return the multiplication quaternion */ Quaternion operator*(Quaternion q); /** * Definition of operator [] * @param Position of the quanternion to be returned. Position 0 corresponds * to the real component and 1, 2, and 3 to the complex components. * @param The value on the specified position is returned. * */ const float& operator[](unsigned int i) const; /** * Operator to print */ friend std::ostream& operator<<(std::ostream& os, const Quaternion& coord); private: //------------------------------------------------------------ //Private methods //------------------------------------------------------------ //------------------------------------------------------------ //Atributes //------------------------------------------------------------ /** * Real part of the quaternion */ float r; /** * Angle between vectors */ float theta; /** * Rotation vector */ Vec3 w; /** * Vector the quaternion */ Vec3 im; }; //------------------------------------------------------------------------------ #endif