00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __HOM_Quaternion_h__
00017 #define __HOM_Quaternion_h__
00018
00019 #include "HOM_API.h"
00020 #include "HOM_Defines.h"
00021 #include "HOM_Errors.h"
00022 #include "HOM_Module.h"
00023 #include "HOM_Vector3.h"
00024 #include <UT/UT_Quaternion.h>
00025 #include <vector>
00026 #include <stdexcept>
00027
00028 class HOM_Matrix3;
00029 class HOM_Matrix4;
00030
00031 SWIGOUT(%rename(Quaternion) HOM_Quaternion;)
00032
00033 class HOM_API HOM_Quaternion
00034 {
00035 public:
00036 HOM_Quaternion() throw(HOM_Error)
00037 : myQuaternion(0.0f, 0.0f, 0.0f, 1.0f)
00038 { HOM_CONSTRUCT_OBJECT(this) }
00039
00040 HOM_Quaternion(float x, float y, float z, float w) throw(HOM_Error)
00041 : myQuaternion(x, y, z, w)
00042 { HOM_CONSTRUCT_OBJECT(this) }
00043
00044 HOM_Quaternion(float angle_in_deg, const std::vector<float> &axis)
00045 throw(HOM_InvalidSize, HOM_Error)
00046 {
00047 setToAngleAxis(angle_in_deg, axis);
00048 HOM_CONSTRUCT_OBJECT(this)
00049 }
00050
00051 HOM_Quaternion(HOM_Matrix3 &matrix3) throw(HOM_Error);
00052 HOM_Quaternion(HOM_Matrix4 &matrix4) throw(HOM_Error);
00053
00054 SWIGOUT(%ignore HOM_Quaternion(const UT_Quaternion&);)
00055 HOM_Quaternion(const UT_Quaternion &quaternion) throw(HOM_Error)
00056 : myQuaternion(quaternion)
00057 { HOM_CONSTRUCT_OBJECT(this) }
00058
00059 ~HOM_Quaternion()
00060 { HOM_DESTRUCT_OBJECT(this) }
00061
00062 bool operator==(HOM_Quaternion &quaternion)
00063 { return myQuaternion == quaternion.myQuaternion; }
00064
00065 bool operator!=(HOM_Quaternion &quaternion)
00066 { return myQuaternion != quaternion.myQuaternion; }
00067
00068 bool isAlmostEqual(HOM_Quaternion &quaternion, float tolerance=0.00001);
00069
00070
00071 bool almostEqual(HOM_Quaternion &quaternion, float tolerance=0.00001)
00072 { return isAlmostEqual(quaternion, tolerance); }
00073
00074 int __hash__();
00075 std::string __str__();
00076 std::string __repr__();
00077
00078 float __getitem__(int index) throw(std::out_of_range);
00079 void __setitem__(int index, float value) throw(std::out_of_range);
00080 int __len__()
00081 { return 4; }
00082
00083 void setTo(const std::vector<float> &tuple) throw(HOM_InvalidSize);
00084
00085 void setToRotationMatrix(HOM_Matrix3 &matrix3) throw(HOM_Error);
00086 void setToRotationMatrix(HOM_Matrix4 &matrix4) throw(HOM_Error);
00087
00088 void setToAngleAxis(float angle_in_deg, const std::vector<float> &axis)
00089 throw(HOM_InvalidSize, HOM_Error);
00090
00091 SWIGOUT(%kwargs setToEulerRotates;)
00092 void setToEulerRotates(
00093 const std::vector<float> &angles_in_deg,
00094 const char *rotate_order="xyz")
00095 throw(HOM_ValueError, HOM_InvalidSize, HOM_Error);
00096
00097 SWIGOUT(%ignore operator=;)
00098 HOM_Quaternion &operator=(const HOM_Quaternion& quaternion)
00099 {
00100 myQuaternion = quaternion.myQuaternion;
00101 return *this;
00102 }
00103
00104 HOM_Quaternion conjugate();
00105 HOM_Quaternion inverse();
00106 float dot(HOM_Quaternion &quaternion)
00107 { return ::dot(myQuaternion, quaternion.myQuaternion); }
00108
00109 HOM_Quaternion __add__(HOM_Quaternion &quaternion)
00110 { return HOM_Quaternion(myQuaternion + quaternion.myQuaternion); }
00111 HOM_Quaternion __sub__(HOM_Quaternion &quaternion)
00112 { return HOM_Quaternion(myQuaternion - quaternion.myQuaternion); }
00113 HOM_Quaternion __mul__(float scalar)
00114 { return HOM_Quaternion(myQuaternion * scalar); }
00115 HOM_Quaternion __mul__(HOM_Quaternion &quaternion);
00116
00117 HOM_Quaternion slerp(HOM_Quaternion &other, float fraction);
00118
00119
00120 HOM_Quaternion normalized();
00121
00122 float length()
00123 { return myQuaternion.length(); }
00124
00125
00126 SWIGOUT(%newobject extractRotationMatrix3;)
00127 HOM_Matrix3 *extractRotationMatrix3();
00128
00129 std::pair<float, HOM_ElemPtr<HOM_Vector3> > extractAngleAxis();
00130
00131 HOM_Vector3 extractEulerRotates(const char *rotate_order="xyz")
00132 throw(HOM_ValueError);
00133
00134
00135 SWIGOUT(%ignore myQuaternion;)
00136 UT_Quaternion myQuaternion;
00137 };
00138
00139 #endif