Go to the
documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 #pragma once
00016 
00017 #include "GeomExport.h"
00018 #include "maxheap.h"
00019 #include "matrix3.h"
00020 #include "quat.h"
00021 
00022 #define EULERTYPE_XYZ   0
00023 #define EULERTYPE_XZY   1
00024 #define EULERTYPE_YZX   2
00025 #define EULERTYPE_YXZ   3
00026 #define EULERTYPE_ZXY   4
00027 #define EULERTYPE_ZYX   5
00028 #define EULERTYPE_XYX   6
00029 #define EULERTYPE_YZY   7
00030 #define EULERTYPE_ZXZ   8
00031 
00032 #define EULERTYPE_RF    16  // rotating frame (axes)  --prs.
00033 
00034 GEOMEXPORT void QuatToEuler(const Quat &q, float *ang, int type, bool flag = false);    
00035 GEOMEXPORT void EulerToQuat(float *ang, Quat &q,int type);
00036 GEOMEXPORT void MatrixToEuler(const Matrix3 &mat, float *ang, int type, bool flag = FALSE);
00037 GEOMEXPORT void EulerToMatrix(float *ang, Matrix3 &mat, int type);
00038 GEOMEXPORT float GetEulerQuatAngleRatio(Quat &quat1,Quat &quat2, float *euler1, float *euler2, int type = EULERTYPE_XYZ);
00039 GEOMEXPORT float GetEulerMatAngleRatio(Matrix3 &mat1,Matrix3 &mat2, float *euler1, float *euler2, int type = EULERTYPE_XYZ);
00040 GEOMEXPORT void ContinuousQuatToEuler(const Quat& quat, float ang[3], int order);
00041 
00091 class RotationValue: public MaxHeapOperators {
00092 
00093 
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00104 
00105 
00106 
00107 
00108 
00109 
00110 
00111 
00112 
00113 
00114 
00115 
00116 
00117 public:
00118     enum EulerType {
00119         kXYZ = EULERTYPE_XYZ,
00120         kXZY,
00121         kYZX,
00122         kYXZ,
00123         kZXY,
00124         kZYX,
00125         kXYX,
00126         kYZY,
00127         kZXZ
00128     };
00129     enum {
00130         kReptd = kXYX,
00131         kQuat = 100
00132     };
00137     static bool IsEuler(int rep) { return (kXYZ <= rep && rep <= kZXZ); }
00143     static bool IsRepetitive(int rep) {
00144         
00145         return rep >= kReptd; }
00150     static bool IsQuat(int rep) { return rep == kQuat; }
00151 
00158     void Set(const Point3& a, EulerType et) {
00159         mQ.x = a.x;
00160         mQ.y = a.y;
00161         mQ.z = a.z;
00162         mRep = (short)et; }
00166     void Set(const Quat& q) {
00167         mQ = q;
00168         mRep = kQuat; }
00170     RotationValue() : mQ(), mRep(kXYZ) {}
00172     RotationValue(const Point3& a, EulerType et) { Set(a, et); }
00175     RotationValue(const Quat& q) { Set(q); }
00177     RotationValue(const RotationValue& src) : mQ(src.mQ), mRep(src.mRep) {}
00178 
00188     Point3 Euler(EulerType et =kXYZ) const {
00189         if (et == mRep) return Point3(mQ.x, mQ.y, mQ.z);
00190         else return ToEulerAngles(et); }
00192     operator Quat() const {
00193         if (mRep == kQuat) return mQ;
00194         else return ToQuat(); }
00196     GEOMEXPORT operator Matrix3() const;
00200     GEOMEXPORT void PreApplyTo(Matrix3& m) const; 
00204     GEOMEXPORT void PostApplyTo(Matrix3& m) const; 
00205     
00206     
00215     GEOMEXPORT void PostRotate(const AngAxis& aa);
00216 
00221     int     NativeRep() const { return mRep; }
00224     Quat    GetNative() const { return mQ; }
00225 
00226     
00227     
00228     
00229     
00230     
00231     
00232     
00233     static const int kAxisToOrdinal[kReptd][3];
00234     static const int kOrdinalToAxis[kZXZ+1][3];
00235 
00236 protected:
00237     GEOMEXPORT Point3   ToEulerAngles(EulerType et) const;
00238     GEOMEXPORT Quat ToQuat() const;
00239 
00240 private:
00241     Quat    mQ;
00242     short   mRep;
00243 };
00244