Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ShQuaternion.hpp

00001 // Sh: A GPU metaprogramming language. 00002 // 00003 // Copyright (c) 2003 University of Waterloo Computer Graphics Laboratory 00004 // Project administrator: Michael D. McCool 00005 // Authors: Zheng Qin, Stefanus Du Toit, Kevin Moule, Tiberiu S. Popa, 00006 // Michael D. McCool 00007 // 00008 // This software is provided 'as-is', without any express or implied 00009 // warranty. In no event will the authors be held liable for any damages 00010 // arising from the use of this software. 00011 // 00012 // Permission is granted to anyone to use this software for any purpose, 00013 // including commercial applications, and to alter it and redistribute it 00014 // freely, subject to the following restrictions: 00015 // 00016 // 1. The origin of this software must not be misrepresented; you must 00017 // not claim that you wrote the original software. If you use this 00018 // software in a product, an acknowledgment in the product documentation 00019 // would be appreciated but is not required. 00020 // 00021 // 2. Altered source versions must be plainly marked as such, and must 00022 // not be misrepresented as being the original software. 00023 // 00024 // 3. This notice may not be removed or altered from any source 00025 // distribution. 00027 #ifndef SHQUATERNION_HPP 00028 #define SHQUATERNION_HPP 00029 00030 #include <iostream> 00031 #include "ShLib.hpp" 00032 00033 namespace SH { 00034 00037 template<ShBindingType B, typename T=float> 00038 class ShQuaternion 00039 { 00040 template <ShBindingType B2, typename T2> 00041 friend std::ostream& operator<<(std::ostream& out, 00042 const ShQuaternion<B2, T2>& q); 00043 public: 00044 00049 ShQuaternion(); 00050 00057 template<ShBindingType B2> 00058 ShQuaternion(const ShQuaternion<B2, T>& other); 00059 00060 00067 template<ShBindingType B2> 00068 ShQuaternion(const ShVector<4, B2, T>& values); 00069 00070 00077 template<ShBindingType B2, ShBindingType B3> 00078 ShQuaternion(const ShAttrib<1, B2, T>& angle, 00079 const ShVector<3, B3, T>& axis); 00080 00081 00088 template<ShBindingType B2> 00089 ShQuaternion(const ShMatrix<4, 4, B2, T>& mat); 00090 00097 template<ShBindingType B2> 00098 ShQuaternion& operator=(const ShQuaternion<B2, T>& other); 00099 00106 template<ShBindingType B2> 00107 ShQuaternion& operator+=(const ShQuaternion<B2, T>& right); 00108 00115 template<ShBindingType B2> 00116 ShQuaternion& operator-=(const ShQuaternion<B2, T>& right); 00117 00124 template<ShBindingType B2> 00125 ShQuaternion& operator*=(const ShQuaternion<B2, T>& right); 00126 00127 00134 template<ShBindingType B2> 00135 ShQuaternion& operator*=(const ShAttrib<1, B2, T>& right); 00136 00143 template<ShBindingType B2> 00144 ShQuaternion& operator*=(const ShVector<3, B2, T>& right); 00145 00152 template<ShBindingType B2> 00153 ShQuaternion& operator*=(const ShNormal<3, B2, T>& right); 00154 00160 template<ShBindingType B2> 00161 ShQuaternion<SH_TEMP, T> operator+(const ShQuaternion<B2, T>& q2); 00162 00168 template<ShBindingType B2> 00169 ShQuaternion<SH_TEMP, T> operator-(const ShQuaternion<B2, T>& q2); 00170 00176 template<ShBindingType B2> 00177 ShQuaternion<SH_TEMP, T> operator*(const ShQuaternion<B2, T>& q2); 00178 00184 template<ShBindingType B2> 00185 ShQuaternion<SH_TEMP, T> operator*(const ShAttrib<1, B2, T>& c); 00186 00193 template<ShBindingType B2> 00194 ShQuaternion<SH_TEMP, T> operator*(const ShVector<3, B2, T>& q2); 00195 00202 template<ShBindingType B2> 00203 ShQuaternion<SH_TEMP, T> operator*(const ShNormal<3, B2, T>& q2); 00204 00209 void normalize(); 00210 00216 void getValues(T values []) const; 00217 00223 void setUnit(bool flag); 00224 00231 void name(const std::string& name); 00232 00237 std::string name() const; 00238 00244 template<ShBindingType B2> 00245 ShAttrib<1, SH_TEMP, T> dot(const ShQuaternion<B2, T>& q) const; 00246 00251 ShQuaternion<SH_TEMP, T> conjugate() const; 00252 00257 ShQuaternion<SH_TEMP, T> inverse() const; 00258 00264 ShMatrix<4, 4, SH_TEMP, T> getMatrix() const; 00265 00270 ShVector<4, SH_TEMP, T> getVector() const; 00271 private: 00272 ShVector<4, B, T> m_data; 00273 }; 00274 00275 template<ShBindingType B, typename T, ShBindingType B2> 00276 extern ShQuaternion<SH_TEMP, T> 00277 operator*(const ShAttrib<1, B2, T>& c, const ShQuaternion<B, T>& q); 00278 00279 template<ShBindingType B1, ShBindingType B2, typename T> 00280 extern ShQuaternion<SH_TEMP, T> 00281 slerp(const ShQuaternion<B1, T>& q1, const ShQuaternion<B2, T>& q2, 00282 const ShAttrib1f& t); 00283 00284 typedef ShQuaternion<SH_INPUT, float> ShInputQuaternionf; 00285 typedef ShQuaternion<SH_OUTPUT, float> ShOutputQuaternionf; 00286 typedef ShQuaternion<SH_TEMP, float> ShQuaternionf; 00287 } 00288 00289 #include "ShQuaternionImpl.hpp" 00290 00291 #endif

Generated on Mon Oct 18 14:17:40 2004 for Sh by doxygen 1.3.7