00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024 #ifndef SHQUATERNION_HPP
00025 #define SHQUATERNION_HPP
00026
00027 #include <iostream>
00028 #include "ShLib.hpp"
00029
00030 namespace SH {
00031
00034 template<ShBindingType B, typename T = float>
00035 class ShQuaternion
00036 {
00037 template <ShBindingType B2, typename T2>
00038 friend std::ostream& operator<<(std::ostream& out,
00039 const ShQuaternion<B2, T2>& q);
00040 public:
00041 typedef typename ShHostType<T>::type HostType;
00042
00047 ShQuaternion();
00048
00055 template<ShBindingType B2>
00056 ShQuaternion(const ShQuaternion<B2, T>& other);
00057
00058
00065 template<ShBindingType B2>
00066 ShQuaternion(const ShAttrib<4, B2, T, SH_VECTOR>& values);
00067
00068
00075 template<ShBindingType B2, ShBindingType B3>
00076 ShQuaternion(const ShAttrib<1, B2, T>& angle,
00077 const ShAttrib<3, B3, T, SH_VECTOR>& axis);
00078
00079
00086 template<ShBindingType B2>
00087 ShQuaternion(const ShMatrix<4, 4, B2, T>& mat);
00088
00095 template<ShBindingType B2>
00096 ShQuaternion& operator=(const ShQuaternion<B2, T>& other);
00097
00104 template<ShBindingType B2>
00105 ShQuaternion& operator+=(const ShQuaternion<B2, T>& right);
00106
00113 template<ShBindingType B2>
00114 ShQuaternion& operator-=(const ShQuaternion<B2, T>& right);
00115
00122 template<ShBindingType B2>
00123 ShQuaternion& operator*=(const ShQuaternion<B2, T>& right);
00124
00125
00132 template<ShBindingType B2>
00133 ShQuaternion& operator*=(const ShAttrib<1, B2, T>& right);
00134
00141 template<ShBindingType B2>
00142 ShQuaternion& operator*=(const ShAttrib<3, B2, T, SH_VECTOR>& right);
00143
00150 template<ShBindingType B2>
00151 ShQuaternion& operator*=(const ShAttrib<3, B2, T, SH_NORMAL>& right);
00152
00158 template<ShBindingType B2>
00159 ShQuaternion<SH_TEMP, T> operator+(const ShQuaternion<B2, T>& q2);
00160
00166 template<ShBindingType B2>
00167 ShQuaternion<SH_TEMP, T> operator-(const ShQuaternion<B2, T>& q2);
00168
00174 template<ShBindingType B2>
00175 ShQuaternion<SH_TEMP, T> operator*(const ShQuaternion<B2, T>& q2);
00176
00182 template<ShBindingType B2>
00183 ShQuaternion<SH_TEMP, T> operator*(const ShAttrib<1, B2, T>& c);
00184
00191 template<ShBindingType B2>
00192 ShQuaternion<SH_TEMP, T> operator*(const ShAttrib<3, B2, T, SH_VECTOR>& q2);
00193
00200 template<ShBindingType B2>
00201 ShQuaternion<SH_TEMP, T> operator*(const ShAttrib<3, B2, T, SH_NORMAL>& q2);
00202
00207 void normalize();
00208
00214 void getValues(HostType values []) const;
00215
00221 void setUnit(bool flag);
00222
00229 void name(const std::string& name);
00230
00235 std::string name() const;
00236
00242 template<ShBindingType B2>
00243 ShAttrib<1, SH_TEMP, T> dot(const ShQuaternion<B2, T>& q) const;
00244
00249 ShQuaternion<SH_TEMP, T> conjugate() const;
00250
00255 ShQuaternion<SH_TEMP, T> inverse() const;
00256
00262 ShMatrix<4, 4, SH_TEMP, T> getMatrix() const;
00263
00268 ShAttrib<4, SH_TEMP, T, SH_VECTOR> getVector() const;
00269 private:
00270 ShAttrib<4, B, T, SH_VECTOR> m_data;
00271 };
00272
00273 template<ShBindingType B, typename T, ShBindingType B2>
00274 extern ShQuaternion<SH_TEMP, T>
00275 operator*(const ShAttrib<1, B2, T>& c, const ShQuaternion<B, T>& q);
00276
00277 template<ShBindingType B1, ShBindingType B2, typename T>
00278 extern ShQuaternion<SH_TEMP, T>
00279 slerp(const ShQuaternion<B1, T>& q1, const ShQuaternion<B2, T>& q2,
00280 const ShAttrib1f& t);
00281
00282 typedef ShQuaternion<SH_INPUT, float> ShInputQuaternionf;
00283 typedef ShQuaternion<SH_OUTPUT, float> ShOutputQuaternionf;
00284 typedef ShQuaternion<SH_TEMP, float> ShQuaternionf;
00285 }
00286
00287 #include "ShQuaternionImpl.hpp"
00288
00289 #endif