00001 /* 00002 ** TP ETI5 CPE Lyon 00003 ** Copyright (C) 2010 Damien Rohmer 00004 ** 00005 ** This program is free software: you can redistribute it and/or modify 00006 ** it under the terms of the GNU General Public License as published by 00007 ** the Free Software Foundation, either version 3 of the License, or 00008 ** (at your option) any later version. 00009 ** 00010 ** This program is distributed in the hope that it will be useful, 00011 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 ** GNU General Public License for more details. 00014 ** 00015 ** You should have received a copy of the GNU General Public License 00016 ** along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 00020 00021 #ifndef _QUATERNION_HPP_ 00022 #define _QUATERNION_HPP_ 00023 00024 #include <v4.hpp> 00025 00026 namespace cpe 00027 { 00028 class v3; 00029 class matrix3; 00030 00032 class quaternion: public v4 00033 { 00034 public: 00035 00036 // ********************************************* // 00037 // ********************************************* // 00038 // CONSTRUCTORS 00039 // ********************************************* // 00040 // ********************************************* // 00041 00043 quaternion(); 00045 quaternion(const v3& axis,const double& angle); 00047 quaternion(const v4& entries); 00048 00049 00050 // ********************************************* // 00051 // ********************************************* // 00052 // GET 00053 // ********************************************* // 00054 // ********************************************* // 00055 00057 v3 axis() const; 00059 double angle() const; 00060 00061 00062 // ********************************************* // 00063 // ********************************************* // 00064 // Math 00065 // ********************************************* // 00066 // ********************************************* // 00067 00068 00072 matrix3 matrix() const; 00073 00075 quaternion conjugated() const; 00076 00082 static quaternion slerp(const quaternion& q0,const quaternion& q1,const double& t); 00083 00085 void compute_w(); 00086 00087 00088 00089 00090 // ********************************************* // 00091 // ********************************************* // 00092 // Operators 00093 // ********************************************* // 00094 // ********************************************* // 00095 00097 friend quaternion operator*(const quaternion& q0,const quaternion& q1); 00099 quaternion& operator*=(const quaternion& q1); 00100 00102 friend v3 operator*(const quaternion& q,const v3& v); 00103 00105 quaternion operator-() const; 00106 00107 private: 00108 00109 }; 00110 } 00111 00112 #endif