FBX SDK Reference Guide: kgeom.h Source File
00001 /**************************************************************************************
00002 
00003  Copyright © 2001 - 2008 Autodesk, Inc. and/or its licensors.
00004  All Rights Reserved.
00005 
00006  The coded instructions, statements, computer programs, and/or related material 
00007  (collectively the "Data") in these files contain unpublished information 
00008  proprietary to Autodesk, Inc. and/or its licensors, which is protected by 
00009  Canada and United States of America federal copyright law and by international 
00010  treaties. 
00011  
00012  The Data may not be disclosed or distributed to third parties, in whole or in
00013  part, without the prior written consent of Autodesk, Inc. ("Autodesk").
00014 
00015  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00016  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
00017  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR ARISING
00018  BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES OF TITLE, 
00019  NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE. 
00020  WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT WARRANT THAT THE OPERATION
00021  OF THE DATA WILL BE UNINTERRUPTED OR ERROR FREE. 
00022  
00023  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
00024  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR EXPENSES
00025  OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE DAMAGES OR OTHER
00026  SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS OF PROFITS, REVENUE
00027  OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR DAMAGES OF ANY KIND),
00028  HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF LIABILITY, WHETHER DERIVED
00029  FROM CONTRACT, TORT (INCLUDING, BUT NOT LIMITED TO, NEGLIGENCE), OR OTHERWISE,
00030  ARISING OUT OF OR RELATING TO THE DATA OR ITS USE OR ANY OTHER PERFORMANCE,
00031  WHETHER OR NOT AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS
00032  OR DAMAGE. 
00033 
00034 **************************************************************************************/
00035 
00036 #ifndef FBXFILESDK_COMPONENTS_KBASELIB_KMATH_KGEOM_H
00037 #define FBXFILESDK_COMPONENTS_KBASELIB_KMATH_KGEOM_H
00038 
00039 #include <fbxfilesdk/components/kbaselib/kbaselib_h.h>
00040 
00041 #ifndef KFBX_PLUGIN
00042     #include <fbxfilesdk/components/kbaselib/klib/kdebug.h>
00043 #else
00044     // -- Since kdebug.h include kaydara.h and that many warning have been
00045     // -- disabled for practical reason. Include kaydara.h for disabling warning only.
00046     #include <fbxfilesdk/components/kbaselib/kaydara.h>
00047 #endif
00048 
00049 #include <fbxfilesdk/components/kbaselib/kmath/kmath.h>
00050 
00051 
00052 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00053 
00054     class KFBX_DLL KgeVertex;
00055     class KFBX_DLL KgeTVector;
00056     class KFBX_DLL KgeRGBVector;
00057     class KFBX_DLL KgeRGBAVector;
00058     class KFBX_DLL KgeRVector;
00059     class KFBX_DLL KgeSVector;
00060     class KFBX_DLL KgeQuaternion;
00061     class KFBX_DLL KgeMatrix;
00062     class KFBX_DLL KgeAMatrix;
00063     class KFBX_DLL KgeRMatrix;
00064     class KFBX_DLL KgeTMatrix;
00065     class KFBX_DLL KgeSMatrix;
00066     class KFBX_DLL KgeXForm;
00067 
00068     typedef KgeTVector KgeVector;
00069 
00070     class KFBX_DLL KgeVertex {
00071     public:
00072         kOGLFloat   x;
00073         kOGLFloat   y;
00074         kOGLFloat   z;
00075         kOGLFloat   w;
00076         K_INLINE KgeVertex()
00077         {
00078             w = 1;
00079         }
00080         K_INLINE KgeVertex(kOGLFloat px, kOGLFloat py, kOGLFloat pz, kOGLFloat pw = 1)
00081         {
00082             x = px;
00083             y = py;
00084             z = pz;
00085             w = pw;
00086         }
00087     };
00088 
00089     class KFBX_DLL KgeTVector {
00090 
00091     public:
00092         double  mData[4];
00093 
00094         inline KgeTVector();
00095         inline KgeTVector(const double pN0, const double pN1, const double pN2);
00096         inline KgeTVector(const double *const pVi);
00097         inline KgeTVector(const float *const pVi);
00098         inline KgeTVector(const KgeTVector& pVi);
00099         inline KgeTVector(const KgeAMatrix& pAi);
00100         inline KgeTVector(const KgeTMatrix& pAi);
00101         inline KgeTVector& Init();
00102         inline KgeTVector& operator=(const double *const pVi);
00103         inline KgeTVector& operator=(const float *const pVi);
00104         inline KgeTVector& operator=(const KgeTVector& pVi);
00105         inline operator const double *() const;
00106 
00107         inline bool operator==(const KgeTVector& pVi) const;
00108         inline bool operator!=(const KgeTVector& pVi) const;
00109 
00110         double& operator[](int pIndex) { return mData[pIndex]; }
00111 
00112     private:
00113         /*** The following methods are NOT functional
00114             They're just there to detect coding errors at compilation time ***/
00115         inline KgeTVector operator + (const KgeTVector &pVector) const; // Not functional; please use KgeAdd instead.
00116         inline KgeTVector operator - (const KgeTVector &pVector) const; // Not functional; please use KgeSub instead.
00117         inline KgeTVector operator * (const KgeTVector &pVector) const; // Not functional; please use KgeMult instead.
00118         inline double  operator ^ (const KgeTVector &pVector) const; // scalar product // Not functional; please use KgeDot instead.
00119         inline KgeTVector &operator += (const KgeTVector &pVector); // Not functional; please use KgeAdd instead.
00120         inline KgeTVector &operator -= (const KgeTVector &pVector); // Not functional; please use KgeSub instead.
00121         inline KgeTVector &operator *= (const KgeTVector &pVector); // Not functional; please use KgeMult instead.
00122 
00123         inline KgeTVector operator * (double pScalar) const; // Not functional; please use KgeMult instead.
00124         inline KgeTVector operator / (double pScalar) const; // Not functional; please use KgeMult instead.
00125         inline KgeTVector &operator *= (double pScalar); // Not functional; please use KgeMult instead.
00126         inline KgeTVector &operator /= (double pScalar); // Not functional; please use KgeMult instead.
00127 
00128     };
00129 
00130 
00131     class KFBX_DLL KgeRGBAVector {
00132 
00133     public:
00134         double  mData[4];
00135 
00136         inline KgeRGBAVector ();
00137         inline KgeRGBAVector (const double pR, const double pG, const double pB, const double pA);
00138         inline KgeRGBAVector (const double *const pVi);
00139         inline KgeRGBAVector (const KgeRGBAVector& pVi);
00140         inline KgeRGBAVector & Init();
00141         inline KgeRGBAVector & operator=(const double *const pVi);
00142         inline KgeRGBAVector & operator=(const KgeRGBAVector& pVi);
00143         inline operator const double *() const;
00144 
00145         inline bool operator==(const KgeRGBAVector& pVi) const;
00146         inline bool operator!=(const KgeRGBAVector& pVi) const;
00147 
00148     private:
00149         /*** The following methods are NOT functional
00150             They're just there to detect coding errors at compilation time ***/
00151         inline KgeRGBAVector operator + (const KgeRGBAVector &/*pVector*/) const {KgeRGBAVector lNullVector; return lNullVector;}
00152         inline KgeRGBAVector operator - (const KgeRGBAVector &/*pVector*/) const {KgeRGBAVector lNullVector; return lNullVector;}
00153         inline KgeRGBAVector operator * (const KgeRGBAVector &/*pVector*/) const {KgeRGBAVector lNullVector; return lNullVector;}
00154         inline double  operator ^ (const KgeRGBAVector &/*pVector*/) const {return 0.0;}
00155         inline KgeRGBAVector &operator += (const KgeRGBAVector &/*pVector*/) {return *this;}
00156         inline KgeRGBAVector &operator -= (const KgeRGBAVector &/*pVector*/) {return *this;}
00157         inline KgeRGBAVector &operator *= (const KgeRGBAVector &/*pVector*/) {return *this;}
00158 
00159         inline KgeRGBAVector operator * (double /*pScalar*/) const {KgeRGBAVector lNullVector; return lNullVector;}
00160         inline KgeRGBAVector operator / (double /*pScalar*/) const {KgeRGBAVector lNullVector; return lNullVector;}
00161         inline KgeRGBAVector &operator *= (double /*pScalar*/) {return *this;}
00162         inline KgeRGBAVector &operator /= (double /*pScalar*/) {return *this;}
00163     };
00164 
00165     class KFBX_DLL KgeRGBVector {
00166 
00167     public:
00168         double  mData[4];
00169 
00170         inline KgeRGBVector ();
00171         inline KgeRGBVector (const double pR, const double pG, const double pB );
00172         inline KgeRGBVector (const double *const pVi);
00173         inline KgeRGBVector (const KgeRGBVector& pVi);
00174         inline KgeRGBVector (const KgeRGBAVector& pVi);
00175         inline KgeRGBVector & Init();
00176         inline KgeRGBVector & operator=(const double *const pVi);
00177         inline KgeRGBVector & operator=(const KgeRGBAVector& pVi);
00178         inline KgeRGBVector & operator=(const KgeRGBVector& pVi);
00179         inline operator const double *() const;
00180 
00181         inline bool operator==(const KgeRGBVector& pVi) const;
00182         inline bool operator!=(const KgeRGBVector& pVi) const;
00183 
00184     private:
00185         /*** The following methods are NOT functional
00186             They're just there to detect coding errors at compilation time ***/
00187         inline KgeRGBVector operator + (const KgeRGBVector &/*pVector*/) const {KgeRGBVector lNullVector; return lNullVector;}
00188         inline KgeRGBVector operator - (const KgeRGBVector &/*pVector*/) const {KgeRGBVector lNullVector; return lNullVector;}
00189         inline KgeRGBVector operator * (const KgeRGBVector &/*pVector*/) const {KgeRGBVector lNullVector; return lNullVector;}
00190         inline double  operator ^ (const KgeRGBVector &/*pVector*/) const {return 0.0;}
00191         inline KgeRGBVector &operator += (const KgeRGBVector &/*pVector*/) {return *this;}
00192         inline KgeRGBVector &operator -= (const KgeRGBVector &/*pVector*/) {return *this;}
00193         inline KgeRGBVector &operator *= (const KgeRGBVector &/*pVector*/) {return *this;}
00194 
00195         inline KgeRGBVector operator * (double /*pScalar*/) const {KgeRGBVector lNullVector; return lNullVector;}
00196         inline KgeRGBVector operator / (double /*pScalar*/) const {KgeRGBVector lNullVector; return lNullVector;}
00197         inline KgeRGBVector &operator *= (double /*pScalar*/) {return *this;}
00198         inline KgeRGBVector &operator /= (double /*pScalar*/) {return *this;}
00199     };
00200 
00201 
00202 
00203     class KFBX_DLL KgeRVector {
00204 
00205     public:
00206         double mData[3];
00207 
00208         inline KgeRVector();
00209         inline KgeRVector(const double pN0, const double pN1, const double pN2);
00210         inline KgeRVector(const double *const pVi);
00211         inline KgeRVector(const KgeRVector& pVi);
00212         inline KgeRVector(const KgeAMatrix& pAi);
00213         inline KgeRVector(const KgeRMatrix& pRi);
00214         inline KgeRVector(const KgeRMatrix& pRi, const int pOrd);
00215         inline KgeRVector(const KgeQuaternion& pQi);
00216         inline KgeRVector(const KgeQuaternion& pQi, const int pOrd);
00217         inline KgeRVector& Init();
00218         inline KgeRVector& operator=(const double *const pVi);
00219         inline KgeRVector& operator=(const KgeRVector& pVi);
00220         inline operator const double *() const;
00221         inline bool operator==(const KgeRVector& pVi) const;
00222         inline bool operator!=(const KgeRVector& pVi) const;
00223     };
00224 
00225     class KFBX_DLL KgeSVector {
00226 
00227     public:
00228         double mData[3];
00229 
00230         inline KgeSVector();
00231         inline KgeSVector(const double pN);
00232         inline KgeSVector(const double pN0, const double pN1, const double pN2);
00233         inline KgeSVector(const double *const pVi);
00234         inline KgeSVector(const KgeSVector& pVi);
00235         inline KgeSVector(const KgeAMatrix& pAi);
00236         inline KgeSVector(const KgeSMatrix& pSi);
00237         inline KgeSVector& Init();
00238         inline KgeSVector& operator=(const double *const pVi);
00239         inline KgeSVector& operator=(const KgeSVector& pVi);
00240         inline operator const double *() const;
00241         inline bool operator==(const KgeSVector& pVi) const;
00242         inline bool operator!=(const KgeSVector& pVi) const;
00243     };
00244 
00245     class KFBX_DLL KgeQuaternion {
00246 
00247     public:
00248         double mData[4];
00249 
00250         inline KgeQuaternion();
00251         inline KgeQuaternion(const double pX, const double pY, const double pZ, const double pW);
00252         inline KgeQuaternion(const double *const pVi);
00253         inline KgeQuaternion(const KgeQuaternion& pVi);
00254         inline KgeQuaternion(const KgeRVector& pVi);
00255         inline KgeQuaternion(const KgeRVector& pVi, const int pOrd);
00256         inline KgeQuaternion(const KgeAMatrix& pAi);
00257         inline KgeQuaternion(const KgeRMatrix& pRi);
00258         inline KgeQuaternion& Init();
00259         inline KgeQuaternion& operator=(const double *const pVi);
00260         inline KgeQuaternion& operator=(const KgeQuaternion& pVi);
00261         inline operator const double *() const;
00262     };
00263 
00264     class KFBX_DLL KgeMatrix {
00265 
00266     public:
00267         double mData[4][4];
00268 
00269         inline KgeMatrix();
00270         inline KgeMatrix(const double (*const pMi)[4]);
00271         inline KgeMatrix(const KgeMatrix& pMi);
00272         inline KgeMatrix& Init();
00273         inline KgeMatrix& operator=(const double (*const pMi)[4]);
00274         inline KgeMatrix& operator=(const KgeMatrix& pMi);
00275         inline operator const double *() const;
00276     };
00277 
00278     class KFBX_DLL KgeAMatrix {
00279 
00280     public:
00281         double mData[4][4];
00282 
00283         inline KgeAMatrix();
00284         inline KgeAMatrix(const KgeTVector& pTi);
00285         inline KgeAMatrix(const KgeRVector& pRi);
00286         inline KgeAMatrix(const KgeRVector& pRi, const int pOrd);
00287         inline KgeAMatrix(const KgeSVector& pSi);
00288         inline KgeAMatrix(const KgeTVector& pTi, const KgeRVector& pRi);
00289         inline KgeAMatrix(const KgeTVector& pTi, const KgeRVector& pRi, const int pOrd);
00290         inline KgeAMatrix(const KgeTVector& pTi, const KgeQuaternion& pQi);
00291         inline KgeAMatrix(const KgeTVector& pTi, const KgeRVector& pRi, const KgeSVector& pSi);
00292         inline KgeAMatrix(const KgeTVector& pTi, const KgeRVector& pRi, const KgeSVector& pSi, const int pOrd);
00293         inline KgeAMatrix(const KgeTVector& pTi, const KgeQuaternion& pQi, const KgeSVector& pSi);
00294         inline KgeAMatrix(const double (*const pAi)[4]);
00295         inline KgeAMatrix(const KgeAMatrix& pAi);
00296         inline KgeAMatrix& Init();
00297         inline KgeAMatrix& operator=(const double (*const pAi)[4]);
00298         inline KgeAMatrix& operator=(const KgeAMatrix& pAi);
00299         inline operator const double *() const;
00300     };
00301 
00302     class KFBX_DLL KgeTMatrix {
00303 
00304     public:
00305         double mData[4][4];
00306         
00307         inline KgeTMatrix();
00308         inline KgeTMatrix(const double pX, const double pY, const double pZ);
00309         inline KgeTMatrix(const double (*const pTi)[4]);
00310         inline KgeTMatrix(const KgeTMatrix& pTi);
00311         inline KgeTMatrix& Init();
00312         inline KgeTMatrix& operator=(const double (*const pTi)[4]);
00313         inline KgeTMatrix& operator=(const KgeTMatrix& pTi);
00314         inline operator const double *() const;
00315     };
00316 
00317     class KFBX_DLL KgeRMatrix {
00318 
00319     public:
00320         double mData[4][4];
00321 
00322         inline KgeRMatrix();
00323         inline KgeRMatrix(const double pX, const double pY, const double pZ);
00324         inline KgeRMatrix(const double pI, const double pJ, const double pK, const int pOrd);
00325         inline KgeRMatrix(const KgeRVector& pVi);
00326         inline KgeRMatrix(const KgeRVector& pVi, const int pOrd);
00327         inline KgeRMatrix(const double (*const pRi)[4]);
00328         inline KgeRMatrix(const KgeRMatrix& pRi);
00329         inline KgeRMatrix(const KgeQuaternion& pQi);
00330         inline KgeRMatrix& Init();
00331         inline KgeRMatrix& operator=(const double (*const pRi)[4]);
00332         inline KgeRMatrix& operator=(const KgeRMatrix& pRi);
00333         inline operator const double *() const;
00334     };
00335 
00336     class KFBX_DLL KgeSMatrix {
00337 
00338     public:
00339         double mData[4][4];
00340 
00341         inline KgeSMatrix();
00342         inline KgeSMatrix(const double pXYZ);
00343         inline KgeSMatrix(const double pX, const double pY, const double pZ);
00344         inline KgeSMatrix(const double (*const pSi)[4]);
00345         inline KgeSMatrix(const KgeSMatrix& pSi);
00346         inline KgeSMatrix& Init();
00347         inline KgeSMatrix& operator=(const double (*const pSi)[4]);
00348         inline KgeSMatrix& operator=(const KgeTMatrix& pSi);
00349         inline operator const double *() const;
00350     };
00351 
00352     class KFBX_DLL KgeLUMatrix {
00353 
00354     public:
00355         double mData[5][4];
00356 
00357         inline KgeLUMatrix();
00358         inline KgeLUMatrix(const KgeMatrix& pMi);
00359         inline KgeLUMatrix& Init();
00360         inline operator const double *() const;
00361     };
00362 
00363     class KFBX_DLL KgeXForm {
00364 
00365         friend inline KgeXForm& KgeMult(KgeXForm& pTo, KgeXForm& pTiA, KgeXForm& pTiB);
00366         friend inline KgeXForm& KgeInvMult(KgeXForm& pTo, KgeXForm& pTiA, KgeXForm& pTiB);
00367 
00368         KgeAMatrix      mM;
00369         KgeQuaternion   mQ;
00370         KgeRVector      mR;
00371 
00372         enum {
00373 
00374             FLAG_M =    1,
00375             FLAG_R =    2,
00376             FLAG_Q =    4,
00377             FLAG_A =    FLAG_M | FLAG_R | FLAG_Q
00378         };
00379         int     mF;
00380 
00381     public:
00382         inline KgeXForm();
00383 
00384         inline KgeXForm(const KgeTVector& pTi);
00385         inline KgeXForm(const KgeRVector& pRi);
00386         inline KgeXForm(const KgeRVector& pRi, const int pOrd);
00387         inline KgeXForm(const KgeSVector& pSi);
00388         inline KgeXForm(const KgeTVector& pTi, const KgeRVector& pRi);
00389         inline KgeXForm(const KgeTVector& pTi, const KgeRVector& pRi, const int pOrd);
00390         inline KgeXForm(const KgeTVector& pTi, const KgeQuaternion& pQi);
00391         inline KgeXForm(const KgeTVector& pTi, const KgeRVector& pRi, const KgeSVector& pSi);
00392         inline KgeXForm(const KgeTVector& pTi, const KgeRVector& pRi, const KgeSVector& pSi, const int pOrd);
00393         inline KgeXForm(const KgeTVector& pTi, const KgeQuaternion& pQi, const KgeSVector& pSi);
00394         inline KgeXForm(const double (*const pAi)[4]);
00395         inline KgeXForm(const KgeAMatrix& pAi);
00396         
00397         inline KgeXForm(KgeXForm& pX);
00398         inline ~KgeXForm();
00399 
00400         inline KgeXForm& Init();
00401 
00402         inline KgeXForm& operator=(const KgeXForm& pXi);
00403         inline KgeXForm& operator=(const KgeAMatrix& pAi);
00404         inline KgeXForm& operator=(const KgeRMatrix& pRi);
00405         inline KgeXForm& operator=(const KgeTMatrix& pTi);
00406         inline KgeXForm& operator=(const double (*const pMi)[4]);
00407 
00408         inline const KgeAMatrix& GetM();
00409         inline const KgeTVector& GetT() const;
00410         inline const KgeTVector& GetI();
00411         inline const KgeTVector& GetJ();
00412         inline const KgeTVector& GetK();
00413         inline double GetTX() const;
00414         inline double GetTY() const;
00415         inline double GetTZ() const;
00416         inline const KgeRVector& GetR();
00417         inline const KgeRVector& GetR(KgeRVector& pRo, const int pOrd);
00418         inline double GetRX();
00419         inline double GetRY();
00420         inline double GetRZ();
00421         inline const KgeQuaternion& GetQ();
00422 
00423         inline const KgeAMatrix& SetM(const KgeAMatrix& pM);
00424         inline const KgeTVector& SetT(const KgeTVector& pT);
00425         inline const KgeTVector& SetT(const double pVx, const double pVy, const double pVz);
00426         inline double SetTX(const double pVx);
00427         inline double SetTY(const double pVy);
00428         inline double SetTZ(const double pVz);
00429         inline const KgeRVector& SetR(const KgeRVector& pR);
00430         inline const KgeRVector& SetR(const KgeRVector& pR, const int pOrd);
00431         inline const KgeRVector& SetR(const double pVx, const double pVy, const double pVz);
00432         inline double SetRX(const double pVx);
00433         inline double SetRY(const double pVy);
00434         inline double SetRZ(const double pVz);
00435         inline const KgeQuaternion& SetQ(const KgeQuaternion& pQ);
00436 
00437         inline KgeXForm& operator*=(const KgeXForm& pXi);
00438         inline KgeXForm& operator/=(const KgeXForm& pXi);
00439     };
00440 
00441     class KRect
00442     {
00443     public: 
00444         int mX;
00445         int mY;
00446         int mW;
00447         int mH;
00448 
00449         KRect();
00450         KRect(int pX, int pY, int pW, int pH);
00451 
00453         int GetLeft()const;
00455         int GetRight()const;
00457         int GetBottom()const;
00459         int GetTop()const;
00460 
00462         void Union(const KRect& pRect);
00464         void Intersection(const KRect& pRect);
00466         bool PointInside(int pX, int pY);
00468         bool HasAnIntersection(const KRect& pRect) const;
00470         bool StrictlyContains(const KRect& pRect) const;
00471         // StrictlyIntersects: pRect crosses or overlaps one of the sides of this Rect.
00472         bool StrictlyIntersects(const KRect& pRect) const; 
00474         void Translate(int pDeltaX, int pDeltaY);
00475     };
00476 
00477 
00478     // Use this to cast a double[4][4] to a KgeAMatrix
00479     #define KgeA_Cast(x) (*((KgeAMatrix*)(double*)x))
00480 
00481     // Use this to cast a double[4] to a KgeVector
00482     #define KgeV_Cast(x) (*((KgeVector*)(double*)x))
00483 
00485     //
00486     //  Vector Utilities
00487     //
00489 
00490     /*
00491     *   KgeLength : Vector Length
00492     */
00493     inline double KgeLength(const KgeVector& pVi)
00494     {
00495         return KmVlength(pVi.mData);
00496     }
00497 
00498     /*
00499     *   KgeLength : Vector Length
00500     */
00501     inline double KgeLength(const KgeVertex& pVi)
00502     {
00503         return Kmvlength( &(pVi.x) );
00504     }
00505 
00506 
00507     /*
00508     *   KgeLength2 : Vector Squared Length
00509     */
00510     inline double KgeLength2(const KgeVector& pVi)
00511     {
00512         return KmVlength2(pVi.mData);
00513     }
00514 
00515     /*
00516     *   KgeDist : Vector Distance
00517     */
00518     inline double KgeDist(const KgeVector& pViA, const KgeVector& pViB)
00519     {
00520         return KmVdist(pViA.mData, pViB.mData);
00521     }
00522 
00523     /*
00524     *   KgeDot : Vector Dot Product
00525     */
00526     inline double KgeDot(const KgeVector& pViA, const KgeVector& pViB)
00527     {
00528         return KmVdotV(pViA.mData, pViB.mData);
00529     }
00530 
00531     /*
00532     *   KgeDot
00533     */
00534     inline float KgeDot( const KgeVertex& pViA, const KgeVertex& pViB )
00535     {
00536         return KmVdotV( &(pViA.x), &(pViB.x));
00537     }
00538 
00539     /*
00540     *   KgeCompare : Translation Vector Compare
00541     */
00542     inline int KgeCompare(const KgeTVector& pViA, const KgeTVector& pViB, const double pThreshold = KM_TOLERANCE)
00543     {
00544         return KmVcmp(pViA.mData, pViB.mData, pThreshold);
00545     }
00546 
00547     /*
00548     *   KgeCompare : Translation RGB Compare
00549     */
00550     inline int KgeCompare(const KgeRGBVector& pViA, const KgeRGBVector& pViB, const double pThreshold = KM_TOLERANCE)
00551     {
00552         return KmVcmp(pViA.mData, pViB.mData, pThreshold);
00553     }
00554 
00555     /*
00556     *   KgeCompare : Vertex Compare
00557     */
00558     inline int KgeCompare(const KgeVertex& pViA, const KgeVertex& pViB, const kOGLFloat pThreshold = KM_TOLERANCE)
00559     {
00560         return Kmvcmp( &(pViA.x), &(pViB.x), pThreshold);  
00561     }
00562 
00563 
00564     /*
00565     *   KgeCompare : Rotation Vector Compare
00566     */
00567     inline int KgeCompare(const KgeRVector& pViA, const KgeRVector& pViB, const double pThreshold = KM_TOLERANCE)
00568     {
00569         return KmRVcmp(pViA.mData, pViB.mData, pThreshold);
00570     }
00571 
00572     /*
00573     *   KgeCompare : Scaling Vector Compare
00574     */
00575     inline int KgeCompare(const KgeSVector& pViA, const KgeSVector& pViB, const double pThreshold = KM_TOLERANCE)
00576     {
00577         return KmVcmp(pViA.mData, pViB.mData, pThreshold);
00578     }
00579 
00581     //
00582     //  Vector Initialization
00583     //
00585 
00586     /*
00587     *   KgeSet : Set Vector
00588     */
00589     inline KgeTVector& KgeSet(KgeTVector& pVo, const double pN0, const double pN1, const double pN2)
00590     {
00591         return *(KgeTVector *) KmV(pVo.mData, pN0, pN1, pN2);
00592     }
00593 
00594     /*
00595     *   KgeSet : Set Vector
00596     */
00597     inline KgeTVector& KgeSet(KgeTVector& pVo, const double pN)
00598     {
00599         return *(KgeTVector *) KmV(pVo.mData, pN, pN, pN);
00600     }
00601 
00602     /*
00603     *   KgeSet : Set Vector
00604     */
00605     inline KgeTVector& KgeSet(KgeTVector& pVo, const KgeTVector& pVi)
00606     {
00607         return *(KgeTVector *) KmVset(pVo.mData, pVi.mData);
00608     }
00609 
00610     /*
00611     *   KgeSet : Set Vector
00612     */
00613     inline KgeRVector& KgeSet(KgeRVector& pVo, const double pN0, const double pN1, const double pN2)
00614     {
00615         return *(KgeRVector *) KmV(pVo.mData, pN0, pN1, pN2);
00616     }
00617 
00618     /*
00619     *   KgeSet : Set Vector
00620     */
00621     inline KgeRVector& KgeSet(KgeRVector& pVo, const double pN)
00622     {
00623         return *(KgeRVector *) KmV(pVo.mData, pN, pN, pN);
00624     }
00625 
00626     /*
00627     *   KgeSet : Set Vector
00628     */
00629     inline KgeRVector& KgeSet(KgeRVector& pVo, const KgeRVector& pVi)
00630     {
00631         return *(KgeRVector *) KmVset(pVo.mData, pVi.mData);
00632     }
00633 
00634     /*
00635     *   KgeSet : Set Vector
00636     */
00637     inline KgeSVector& KgeSet(KgeSVector& pVo, const double pN0, const double pN1, const double pN2)
00638     {
00639         return *(KgeSVector *) KmV(pVo.mData, pN0, pN1, pN2);
00640     }
00641 
00642     /*
00643     *   KgeSet : Set Vector
00644     */
00645     inline KgeSVector& KgeSet(KgeSVector& pVo, const double pN)
00646     {
00647         return *(KgeSVector *) KmV(pVo.mData, pN, pN, pN);
00648     }
00649 
00650     /*
00651     *   KgeSet : Set Vector
00652     */
00653     inline KgeSVector& KgeSet(KgeSVector& pVo, const KgeSVector& pVi)
00654     {
00655         return *(KgeSVector *) KmVset(pVo.mData, pVi.mData);
00656     }
00657 
00658 
00659     /*
00660     *   KgeSet : Set Vertex
00661     */
00662     inline KgeVertex& KgeSet(KgeVertex& pVo, const KgeVertex& pVi)
00663     {
00664         return *(KgeVertex *) KmVset( &(pVo.x), &(pVi.x));
00665     }
00666 
00667     /*
00668     *   KgeSet : Set Vertex from vector
00669     */
00670     inline KgeVertex& KgeSet(KgeVertex& pVo, const KgeVector& pVi)
00671     {
00672         return *(KgeVertex *) KmVset( &(pVo.x), pVi.mData);
00673     }
00674 
00675 
00676     /*
00677     *   KgeSet : Set Vector from vertex
00678     */
00679     inline KgeTVector& KgeSet(KgeTVector& pVo, const KgeVertex& pVi)
00680     {
00681         return *(KgeTVector *) KmVset( pVo.mData, &(pVi.x));
00682     }
00683 
00684 
00685     /*
00686     *   KgeSet : Set Vertex
00687     */
00688     inline KgeVertex& KgeSet(KgeVertex& pVo, const float x, const float y, const float z )
00689     {
00690         return *(KgeVertex *) KmV( &(pVo.x), x, y, z); 
00691     }
00692 
00694     //
00695     //  Vector Operations
00696     //
00698 
00699     /*
00700     *   KgeNeg : Vector Negate
00701     */
00702     inline KgeVector& KgeNeg(KgeVector& pVo, KM_CONST KgeVector& pVi)
00703     {
00704         return *(KgeVector *) KmVneg(pVo.mData, pVi.mData);
00705     }
00706 
00707     /*
00708     *   KgeAdd : Vector Add
00709     */
00710     inline KgeVector& KgeAdd(KgeVector& pVo, KM_CONST KgeVector& pViA, KM_CONST KgeVector& pViB)
00711     {
00712         return *(KgeVector *) KmVadd(pVo.mData, pViA.mData, pViB.mData);
00713     }
00714 
00715     /*
00716     *   KgeAdd : Vertex Add
00717     */
00718     inline KgeVertex& KgeAdd(KgeVertex& pVo, KM_CONST KgeVertex& pViA, KM_CONST KgeVertex& pViB)
00719     {
00720         return *(KgeVertex *) KmVadd( &(pVo.x), &(pViA.x), &(pViB.x) );
00721     }
00722 
00723 
00724     /*
00725     *   KgeSub : Vector Substract
00726     */
00727     inline KgeVector& KgeSub(KgeVector& pVo, KM_CONST KgeVector& pViA, KM_CONST KgeVector& pViB)
00728     {
00729         return *(KgeVector *) KmVsub(pVo.mData, pViA.mData, pViB.mData);
00730     }
00731 
00732     /*
00733     *   KgeSub : Vertex Substract
00734     */
00735     inline KgeVector& KgeSub(KgeVector& pVo, KM_CONST KgeVertex& pViA, KM_CONST KgeVertex& pViB)
00736     {
00737         return *(KgeVector *) KmVsub( pVo.mData, &(pViA.x), &(pViB.x) );
00738     }
00739 
00740     inline KgeVertex& KgeSub(KgeVertex& pVo, KM_CONST KgeVertex& pViA, KM_CONST KgeVertex& pViB)
00741     {
00742         return *(KgeVertex *) KmVsub(&(pVo.x), &(pViA.x), &(pViB.x) );
00743     }
00744 
00745     /*
00746     *   KgeRev : Vector Reverse
00747     */
00748     inline KgeVector& KgeRev(KgeVector& pVo, KM_CONST KgeVector& pVi)
00749     {
00750         return *(KgeVector *) KmVrev(pVo.mData, pVi.mData);
00751     }
00752 
00753     /*
00754     *   KgeVV : Vertex Cross Product
00755     */
00756     inline KgeVertex& KgeMult( KgeVertex& pVo, KM_CONST KgeVertex& pViA, KM_CONST KgeVertex& pViB )
00757     {
00758         return *(KgeVertex*) Kmvv( &(pVo.x), &(pViA.x), &(pViB.x) );
00759     }
00760 
00761 
00762     /*
00763     *   KgeVV : Vector Cross Product
00764     */
00765     inline KgeVector& KgeMult(KgeVector& pVo, KM_CONST KgeVector& pViA, KM_CONST KgeVector& pViB)
00766     {
00767         return *(KgeVector *) KmVV(pVo.mData, pViA.mData, pViB.mData);
00768     }
00769 
00770 
00771     /*
00772     *   KgeMult : Vertex Times Scalar
00773     */
00774     inline KgeVertex& KgeMult(KgeVertex& pVo, KM_CONST KgeVertex& pVi, const kOGLFloat pNi)
00775     {
00776         return *(KgeVertex *) Kmvn( &(pVo.x), &(pVi.x), pNi);
00777     }
00778 
00779 
00780     /*
00781     *   KgeMult : Vector Times Scalar
00782     */
00783     inline KgeVector& KgeMult(KgeVector& pVo, KM_CONST KgeVector& pVi, const double pNi)
00784     {
00785         return *(KgeVector *) KmVN(pVo.mData, pVi.mData, pNi);
00786     }
00787 
00788 
00789     /*
00790     *   KgeMult : RVector Times Scalar
00791     */
00792     inline KgeRVector& KgeMult(KgeRVector& pVo, KM_CONST KgeRVector& pVi, const double pNi)
00793     {
00794         return *(KgeRVector *) KmVN(pVo.mData, pVi.mData, pNi);
00795     }
00796 
00797 
00798     /*
00799     *   KgeMult : SVector Times Scalar
00800     */
00801     inline KgeSVector& KgeMult(KgeSVector& pVo, KM_CONST KgeSVector& pVi, const double pNi)
00802     {
00803         return *(KgeSVector *) KmVN(pVo.mData, pVi.mData, pNi);
00804     }
00805 
00806 
00807 
00808 
00809     /*
00810     *   KgeNorm : Vector Normalize
00811     */
00812     inline KgeVector& KgeNorm(KgeVector& pVo, KM_CONST KgeVector& pVi)
00813     {
00814         return *(KgeVector *) KmVnorm(pVo.mData, pVi.mData);
00815     }
00816 
00817     /*
00818     *   KgeNorm : Vertex Normalize
00819     */
00820     inline KgeVertex& KgeNorm(KgeVertex& pVo, KM_CONST KgeVertex& pVi)
00821     {
00822         return *(KgeVertex *) KmVnorm( &(pVo.x), &(pVi.x));
00823     }
00824 
00825     /*
00826     *   KgeMult : Matrix by Vector Product
00827     */
00828     inline KgeVector& KgeMult(KgeVector& pVo, const KgeMatrix& pMi, KM_CONST KgeVector& pVi)
00829     {
00830         return *(KgeVector *) KmMV(pVo.mData, pMi.mData, pVi.mData);
00831     }
00832 
00833     /*
00834     *   KgeMult : Matrix by Vertex Product
00835     */
00836     inline KgeVertex& KgeMult(KgeVertex& pVo, const KgeMatrix& pMi, KM_CONST KgeVertex& pVi)
00837     {
00838         return *(KgeVertex *) KmMv( &(pVo.x), pMi.mData, &(pVi.x) );
00839     }
00840 
00841 
00842     /*
00843     *   KgeMult : Affine Matrix by Vector Product
00844     */
00845     inline KgeVector& KgeMult(KgeVector& pVo, const KgeAMatrix& pAi, KM_CONST KgeVector& pVi)
00846     {
00847         return *(KgeVector *) KmAV(pVo.mData, pAi.mData, pVi.mData);
00848     }
00849 
00850     /*
00851     *   KgeMult : Affine Matrix by Vertex Product
00852     */
00853     inline KgeVertex& KgeMult(KgeVertex& pvo, const KgeAMatrix& pAi, KM_CONST KgeVertex& pvi)
00854     {
00855         return *(KgeVertex *) KmAv( &(pvo.x), pAi.mData, &(pvi.x) );
00856     }
00857 
00858     /*
00859     *   KgeMult : Translation Matrix by Vector Product
00860     */
00861     inline KgeVector& KgeMult(KgeVector& pVo, const KgeTMatrix& pTi, KM_CONST KgeVector& pVi)
00862     {
00863         return *(KgeVector *) KmTV(pVo.mData, pTi.mData, pVi.mData);
00864     }
00865 
00866     /*
00867     *   KgeMult : Rotation Matrix by Vector Product
00868     */
00869     inline KgeVector& KgeMult(KgeVector& pVo, const KgeRMatrix& pRi, KM_CONST KgeVector& pVi)
00870     {
00871         return *(KgeVector *) KmRV(pVo.mData, pRi.mData, pVi.mData);
00872     }
00873 
00874     /*
00875     *   KgeMult : Rotation Matrix by Vertex Product
00876     */
00877     inline KgeVertex& KgeMult(KgeVertex& pVo, const KgeRMatrix& pRi, KM_CONST KgeVertex& pVi)
00878     {
00879         return *(KgeVertex *) KmRV( &(pVo.x), pRi.mData, &(pVi.x) );
00880     }
00881 
00882 
00883     /*
00884     *   KgeMult : Scaling Matrix by Vector Product
00885     */
00886     inline KgeVector& KgeMult(KgeVector& pVo, const KgeSMatrix& pSi, KM_CONST KgeVector& pVi)
00887     {
00888         return *(KgeVector *) KmSV(pVo.mData, pSi.mData, pVi.mData);
00889     }
00890 
00892     //
00893     //  Quaternion Utilities
00894     //
00896 
00897     /*
00898     *   KgeCompare : Quaternion Length
00899     */
00900     inline double KgeLength(const KgeQuaternion& pQi)
00901     {
00902         return KmQlength(pQi.mData);
00903     }
00904 
00905     /*
00906     *   KgeCompare : Quaternion Squared Length
00907     */
00908     inline double KgeLength2(const KgeQuaternion& pQi)
00909     {
00910         return KmQlength2(pQi.mData);
00911     }
00912 
00913     /*
00914     *   KgeCompare : Quaternion Dot Product
00915     */
00916     inline double KgeDot(const KgeQuaternion& pQiA, const KgeQuaternion& pQiB)
00917     {
00918         return KmQdotQ(pQiA.mData, pQiB.mData);
00919     }
00920 
00921     /*
00922     *   KgeCompare : Quaternion Compare
00923     */
00924     inline int KgeCompare(const KgeQuaternion& pQiA, const KgeQuaternion& pQiB, const double pThreshold = KM_TOLERANCE)
00925     {
00926         return KmQcmp(pQiA.mData, pQiB.mData, pThreshold);
00927     }
00928 
00930     //
00931     //  Quaternion Initialization
00932     //
00934 
00935     /*
00936     *   KgeSet : Set Quaternion
00937     */
00938     inline KgeQuaternion& KgeSet(
00939         KgeQuaternion& pQo,
00940         const double pX, const double pY, const double pZ, const double pW)
00941     {
00942         return *(KgeQuaternion *) KmQ(pQo.mData, pX, pY, pZ, pW);
00943     }
00944 
00945     /*
00946     *   KgeSet : Set Quaternion
00947     */
00948     inline KgeQuaternion& KgeSet(
00949         KgeQuaternion& pQo, const KgeQuaternion& pQi)
00950     {
00951         return *(KgeQuaternion *) KmQset(pQo.mData, pQi.mData);
00952     }
00953 
00954     /*
00955     *   KgeSet : Set Quaternion
00956     */
00957     inline KgeQuaternion& KgeSet(
00958         KgeQuaternion& pQo, const KgeRMatrix& pRi)
00959     {
00960         return *(KgeQuaternion *) KmRtoQ(pQo.mData, pRi.mData);
00961     }
00962 
00963     /*
00964     *   KgeUnRoll : Euler Angle Un-Roller
00965     */
00966     inline KgeRVector& KgeUnRoll(KgeRVector& pRo, KM_CONST KgeRVector& pVi, const KgeRVector& pRi)
00967     {
00968         return *(KgeRVector *) KmRunroll(pRo.mData, pVi.mData, pRi.mData);
00969     }
00970 
00971     /*
00972     *   KgeSetXYZ : XYZ Euler Vector To Quaternion
00973     */
00974     inline KgeQuaternion& KgeSetXYZ(KgeQuaternion& pQo, const KgeRVector& pVi)
00975     {
00976         return *(KgeQuaternion *) KmVXYZtoQ(pQo.mData, pVi.mData);
00977     }
00978      
00979     /*
00980     *   KgeSetYZX : YZX Euler Vector To Quaternion
00981     */
00982     inline KgeQuaternion& KgeSetYZX(KgeQuaternion& pQo, const KgeRVector& pVi)
00983     {
00984         return *(KgeQuaternion *) KmVYZXtoQ(pQo.mData, pVi.mData);
00985     }
00986 
00987     /*
00988     *   KgeSetZXY : ZXY Euler Vector To Quaternion
00989     */
00990     inline KgeQuaternion& KgeSetZXY(KgeQuaternion& pQo, const KgeRVector& pVi)
00991     {
00992         return *(KgeQuaternion *) KmVZXYtoQ(pQo.mData, pVi.mData);
00993     }
00994 
00995     /*
00996     *   KgeSetXZY : XZY Euler Vector To Quaternion
00997     */
00998     inline KgeQuaternion& KgeSetXZY(KgeQuaternion& pQo, const KgeRVector& pVi)
00999     {
01000         return *(KgeQuaternion *) KmVXZYtoQ(pQo.mData, pVi.mData);
01001     }
01002      
01003     /*
01004     *   KgeSetYXZ : YXZ Euler Vector To Quaternion
01005     */
01006     inline KgeQuaternion& KgeSetYXZ(KgeQuaternion& pQo, const KgeRVector& pVi)
01007     {
01008         return *(KgeQuaternion *) KmVYXZtoQ(pQo.mData, pVi.mData);
01009     }
01010 
01011     /*
01012     *   KgeSetZYX : ZYX Euler Vector To Quaternion
01013     */
01014     inline KgeQuaternion& KgeSetZYX(KgeQuaternion& pQo, const KgeRVector& pVi)
01015     {
01016         return *(KgeQuaternion *) KmVZYXtoQ(pQo.mData, pVi.mData);
01017     }
01018 
01019     /*
01020     *   KgeSet : Ordered Euler Vector To Quaternion
01021     */
01022     inline KgeQuaternion& KgeSet(KgeQuaternion& pQo, const KgeRVector& pVi, const int pOrd)
01023     {
01024         return *(KgeQuaternion *) KmVIJKtoQ(pQo.mData, pVi.mData, pOrd);
01025     }
01026 
01027     /*
01028     *   KgeSet : Default Order Euler Vector To Quaternion
01029     */
01030     inline KgeQuaternion& KgeSet(KgeQuaternion& pQo, const KgeRVector& pVi)
01031     {
01032         return *(KgeQuaternion *) KmVtoQ(pQo.mData, pVi.mData);
01033     }
01034 
01036     //
01037     //  Quaternion Operations
01038     //
01040 
01041     inline KgeQuaternion& KgeConj(
01042         KgeQuaternion& pQo, KM_CONST  KgeQuaternion& pQi)
01043     {
01044         return *(KgeQuaternion *) KmQconj(pQo.mData, pQi.mData);
01045     }
01046 
01047     inline KgeQuaternion& KgeMult(
01048         KgeQuaternion& pQo, KM_CONST  KgeQuaternion& pQi, const double pNi)
01049     {
01050         return *(KgeQuaternion *) KmQN(pQo.mData, pQi.mData, pNi);
01051     }
01052 
01053     inline KgeQuaternion& KgeNorm(
01054         KgeQuaternion& pQo, KM_CONST  KgeQuaternion& pQi)
01055     {
01056         return *(KgeQuaternion *) KmQnorm(pQo.mData, pQi.mData);
01057     }
01058 
01059     inline KgeQuaternion& KgeAdd(
01060         KgeQuaternion& pQo, KM_CONST KgeQuaternion& pQiA, KM_CONST KgeQuaternion& pQiB)
01061     {
01062         return *(KgeQuaternion *) KmQadd(pQo.mData, pQiA.mData, pQiB.mData);
01063     }
01064 
01065     inline KgeQuaternion& KgeMult(
01066         KgeQuaternion& pQo, KM_CONST KgeQuaternion& pQiA, KM_CONST KgeQuaternion& pQiB)
01067     {
01068         return *(KgeQuaternion *) KmQQ(pQo.mData, pQiA.mData, pQiB.mData);
01069     }
01070 
01072     //
01073     //  Matrix Utilities
01074     //
01076 
01077     /*
01078     *   KgeDet : Affine Matrix Determinant
01079     */
01080     inline double KgeDet(const KgeAMatrix &pAi)
01081     {
01082         return KmAdet(pAi.mData);
01083     }
01084                                                         
01085     /*
01086     *   KgeDet : Translation Matrix Determinant
01087     */
01088     inline double KgeDet(const KgeTMatrix& pTi)
01089     {
01090         return KmTdet(pTi.mData);
01091     }
01092 
01093     /*
01094     *   KgeDet : Rotation Matrix Determinant
01095     */
01096     inline double KgeDet(const KgeRMatrix& pRi)
01097     {
01098         return KmRdet(pRi.mData);
01099     }
01100 
01101     /*
01102     *   KgeDet : Scaling Matrix Determinant
01103     */
01104     inline double KgeDet(const KgeSMatrix& pSi)
01105     {
01106         return KmSdet(pSi.mData);
01107     }
01108 
01109     /*
01110     *   KgeTrace : Affine Matrix Trace
01111     */
01112     inline double KgeTrace(const KgeAMatrix& pAi)
01113     {
01114         return KmAtrace(pAi.mData);
01115     }
01116 
01117     /*
01118     *   KgeTrace : Translation Matrix Trace
01119     */
01120     inline double KgeTrace(const KgeTMatrix& pTi)
01121     {
01122         return KmTtrace(pTi.mData);
01123     }
01124 
01125     /*
01126     *   KgeTrace : Rotation Matrix Trace
01127     */
01128     inline double KgeTrace(const KgeRMatrix& pRi)
01129     {
01130         return KmRtrace(pRi.mData);
01131     }
01132 
01133     /*
01134     *   KgeTrace : Scaling Matrix Trace
01135     */
01136     inline double KgeTrace(const KgeSMatrix& pSi)
01137     {
01138         return KmStrace(pSi.mData);
01139     }
01140 
01141     /*
01142     *   KgeCompare : Matrix Compare
01143     */
01144     inline int KgeCompare(const KgeMatrix& pMiA, const KgeMatrix& pMiB, const double pThreshold = KM_TOLERANCE)
01145     {
01146         return KmMcmp(pMiA.mData, pMiB.mData, pThreshold);
01147     }
01148 
01149     /*
01150     *   KgeCompare : Affine Matrix Compare
01151     */
01152     inline int KgeCompare(const KgeAMatrix& pAiA, const KgeAMatrix& pAiB, const double pThreshold = KM_TOLERANCE)
01153     {
01154         return KmAcmp(pAiA.mData, pAiB.mData, pThreshold);
01155     }
01156 
01157     /*
01158     *   KgeCompare : Translation Matrix Compare
01159     */
01160     inline int KgeCompare(const KgeTMatrix& pTiA, const KgeTMatrix& pTiB, const double pThreshold = KM_TOLERANCE)
01161     {
01162         return KmTcmp(pTiA.mData, pTiB.mData, pThreshold);
01163     }
01164 
01165     /*
01166     *   KgeCompare : Rotation Matrix Compare
01167     */
01168     inline int KgeCompare(const KgeRMatrix& pRiA, const KgeRMatrix& pRiB, const double pThreshold = KM_TOLERANCE)
01169     {
01170         return KmRcmp(pRiA.mData, pRiB.mData, pThreshold);
01171     }
01172 
01173     /*
01174     *   KgeCompare : Scaling Matrix Compare
01175     */
01176     inline int KgeCompare(const KgeSMatrix& pSiA, const KgeSMatrix& pSiB, const double pThreshold = KM_TOLERANCE)
01177     {
01178         return KmScmp(pSiA.mData, pSiB.mData, pThreshold);
01179     }
01180 
01182     //
01183     //  Matrix Initialization
01184     //
01186 
01187     /*
01188     *   KgeIdentity : Matrix Identity
01189     */
01190     inline KgeMatrix& KgeIdentity(KgeMatrix &pMo)
01191     {
01192         return *(KgeMatrix *) KmId(pMo.mData);
01193     }
01194 
01195     /*
01196     *   KgeSet : Set Matrix
01197     */
01198     inline KgeMatrix& KgeSet(KgeMatrix& pMo, const KgeMatrix& pMi)
01199     {
01200         return *(KgeMatrix *) KmMset(pMo.mData, pMi.mData);
01201     }
01202 
01203     /*
01204     *   KgeSet : Set Affine Matrix
01205     */
01206     inline KgeAMatrix& KgeSet(KgeAMatrix& pAo, const KgeAMatrix& pAi)
01207     {
01208         return *(KgeAMatrix *) KmAset(pAo.mData, pAi.mData);
01209     }
01210 
01211     /*
01212     *   KgeSet : Set Affine Matrix with Translation
01213     */
01214     inline KgeAMatrix& KgeSet(KgeAMatrix& pAo, const KgeTMatrix& pAi)
01215     {
01216         return *(KgeAMatrix *) KmTset(pAo.mData, pAi.mData);
01217     }
01218 
01219     /*
01220     *   KgeSet : Set Translation Matrix
01221     */
01222     inline KgeTMatrix& KgeSet(KgeTMatrix& pTo, const KgeTMatrix& pTi)
01223     {
01224         return *(KgeTMatrix *) KmTset(pTo.mData, pTi.mData);
01225     }
01226 
01227     /*
01228     *   KgeSet : Set Rotation Matrix
01229     */
01230     inline KgeRMatrix& KgeSet(KgeRMatrix& pRo, const KgeRMatrix& pRi)
01231     {
01232         return *(KgeRMatrix *) KmRset(pRo.mData, pRi.mData);
01233     }
01234 
01235     /*
01236     *   KgeSet : Set Scaling Matrix
01237     */
01238     inline KgeSMatrix& KgeSet(KgeSMatrix& pSo, const KgeSMatrix& pSi)
01239     {
01240         return *(KgeSMatrix *) KmSset(pSo.mData, pSi.mData);
01241     }
01242 
01244     //
01245     //  Matrix Operations
01246     //
01248 
01249     /*
01250     *   KgeTranspose : Matrix Transpose
01251     */
01252     inline KgeMatrix& KgeTranspose(KgeMatrix& pMo, KM_CONST KgeMatrix& pMi)
01253     {
01254         return *(KgeMatrix *) KmMt(pMo.mData, pMi.mData);
01255     }
01256 
01257     /*
01258     *   KgeAdj : Matrix Adjoint
01259     */
01260     inline KgeMatrix& KgeAdj(KgeMatrix& pMo, const KgeMatrix& pMi)
01261     {
01262         return *(KgeMatrix *) KmMadj(pMo.mData, (const double (*)[4]) pMi.mData);
01263     }
01264 
01265     /*
01266     *   KgeNeg : Matrix Negate
01267     */
01268     inline KgeMatrix& KgeNeg(KgeMatrix& pMo, KM_CONST KgeMatrix& pMi)
01269     {
01270         return *(KgeMatrix *) KmMneg(pMo.mData, pMi.mData);
01271     }
01272 
01273     /*
01274     *   KgeInverse : Matrix Inverse
01275     */
01276     inline KgeMatrix& KgeInverse(KgeMatrix& pMo, KM_CONST KgeMatrix& pMi)
01277     {
01278         return *(KgeMatrix *) KmMi(pMo.mData, pMi.mData);
01279     }
01280 
01281     /*
01282     *   KgeInverse : Affine Matrix Inverse
01283     */
01284     inline KgeAMatrix& KgeInverse(KgeAMatrix& pAo, KM_CONST KgeAMatrix& pAi)
01285     {
01286         return *(KgeAMatrix *) KmAi(pAo.mData, pAi.mData);
01287     }
01288 
01289     /*
01290     *   KgeInverse : Translation Matrix Inverse
01291     */
01292     inline KgeTMatrix& KgeInverse(KgeTMatrix& pTo, KM_CONST KgeTMatrix& pTi)
01293     {
01294         return *(KgeTMatrix *) KmTi(pTo.mData, pTi.mData);
01295     }
01296 
01297     /*
01298     *   KgeInverse : Rotation Matrix Inverse
01299     */
01300     inline KgeRMatrix& KgeInverse(KgeRMatrix& pRo, KM_CONST KgeRMatrix& pRi)
01301     {
01302         return *(KgeRMatrix *) KmRi(pRo.mData, pRi.mData);
01303     }
01304 
01305     /*
01306     *   KgeInverse : Scaling Matrix Inverse
01307     */
01308     inline KgeSMatrix& KgeInverse(KgeSMatrix& pSo, KM_CONST KgeSMatrix& pSi)
01309     {
01310         return *(KgeSMatrix *) KmSi(pSo.mData, pSi.mData);
01311     }
01312 
01313     /*
01314     *   KgeAdd : Matrix Add
01315     */
01316     inline KgeMatrix& KgeAdd(KgeMatrix& pMo, KM_CONST KgeMatrix& pMiA, KM_CONST KgeMatrix& pMiB)
01317     {
01318         return *(KgeMatrix *) KmMadd(pMo.mData, pMiA.mData, pMiB.mData);
01319     }
01320 
01321     /*
01322     *   KgeSub : Matrix Substract
01323     */
01324     inline KgeMatrix& KgeSub(KgeMatrix& pMo, KM_CONST KgeMatrix& pMiA, KM_CONST KgeMatrix& pMiB)
01325     {
01326         return *(KgeMatrix *) KmMsub(pMo.mData, pMiA.mData, pMiB.mData);
01327     }
01328 
01329     /*
01330     *   KgeMult : Matrix Scale
01331     */
01332     inline KgeMatrix& KgeMult(KgeMatrix& pMo, KM_CONST KgeMatrix& pMiA, const double pNi)
01333     {
01334         return *(KgeMatrix *) KmMN(pMo.mData, pMiA.mData, pNi);
01335     }
01336 
01337     /*
01338     *   KgeMult : Matrix Product
01339     */
01340     inline KgeMatrix& KgeMult(KgeMatrix& pMo, KM_CONST KgeMatrix& pMiA, KM_CONST KgeMatrix& pMiB)
01341     {
01342         return *(KgeMatrix *) KmMM(pMo.mData, pMiA.mData, pMiB.mData);
01343     }
01344 
01345     /*
01346     *   KgeMult : Affine Matrix Product
01347     */
01348     inline KgeAMatrix& KgeMult(KgeAMatrix& pAo, KM_CONST KgeAMatrix& pAiA, KM_CONST KgeAMatrix& pAiB)
01349     {
01350         return *(KgeAMatrix *) KmAA(pAo.mData, pAiA.mData, pAiB.mData);
01351     }
01352 
01353     /*
01354     *   KgeMult : Translation Matrix Product
01355     */
01356     inline KgeTMatrix& KgeMult(KgeTMatrix& pTo, KM_CONST KgeTMatrix& pTiA, KM_CONST KgeTMatrix& pTiB)
01357     {
01358         return *(KgeTMatrix *) KmTT(pTo.mData, pTiA.mData, pTiB.mData);
01359     }
01360 
01361     /*
01362     *   KgeMult : Rotation Matrix Product
01363     */
01364     inline KgeRMatrix& KgeMult(KgeRMatrix& pRo, KM_CONST KgeRMatrix& pRiA, KM_CONST KgeRMatrix& pRiB)
01365     {
01366         return *(KgeRMatrix *) KmRR(pRo.mData, pRiA.mData, pRiB.mData);
01367     }
01368 
01369     /*
01370     *   KgeMult : Scaling Matrix Product
01371     */
01372     inline KgeSMatrix& KgeMult(KgeSMatrix& pSo, KM_CONST KgeSMatrix& pSiA, KM_CONST KgeSMatrix& pSiB)
01373     {
01374         return *(KgeSMatrix *) KmSS(pSo.mData, pSiA.mData, pSiB.mData);
01375     }
01376 
01377     /*
01378     *   KgeMult : T by R Matrix Product
01379     */
01380     inline KgeAMatrix& KgeMult(KgeAMatrix& pAo, const KgeTMatrix& pTi, const KgeRMatrix& pRi)
01381     {
01382         return *(KgeAMatrix *) KmTR(pAo.mData, pTi.mData, pRi.mData);
01383     }
01384 
01385     /*
01386     *   KgeMult : T by R by S Matrix Product
01387     */
01388     inline KgeAMatrix& KgeMult(KgeAMatrix& pAo, const KgeTMatrix& pTi, const KgeRMatrix& pRi, const KgeSMatrix& pSi)
01389     {
01390         return *(KgeAMatrix *) KmTRS(pAo.mData, pTi.mData, pRi.mData, pSi.mData);
01391     }
01392 
01393     /*
01394     *   KgeMult : S Matrix Product
01395     */
01396     inline KgeAMatrix& KgeMult(KgeAMatrix& pAo, KM_CONST KgeAMatrix& pAi, const KgeSVector& pVi)
01397     {
01398         double T;
01399 
01400         T = pVi.mData[0];
01401 
01402         pAo.mData[0][0] = pAi.mData[0][0] * T;
01403         pAo.mData[0][1] = pAi.mData[0][1] * T;
01404         pAo.mData[0][2] = pAi.mData[0][2] * T;
01405 
01406         T = pVi.mData[1];
01407 
01408         pAo.mData[1][0] = pAi.mData[1][0] * T;
01409         pAo.mData[1][1] = pAi.mData[1][1] * T;
01410         pAo.mData[1][2] = pAi.mData[1][2] * T;
01411 
01412         T = pVi.mData[2];
01413 
01414         pAo.mData[2][0] = pAi.mData[2][0] * T;
01415         pAo.mData[2][1] = pAi.mData[2][1] * T;
01416         pAo.mData[2][2] = pAi.mData[2][2] * T;
01417 
01418         return pAo;
01419     }
01420 
01421     /*
01422     *   KgeMult : T Vector Product
01423     */
01424     inline KgeAMatrix& KgeMult(KgeAMatrix& pAo, KM_CONST KgeAMatrix& pAi, const KgeTVector& pVi)
01425     {
01426         pAo.mData[3][0] = pAi.mData[3][0] + pVi.mData[0];
01427         pAo.mData[3][1] = pAi.mData[3][1] + pVi.mData[1];
01428         pAo.mData[3][2] = pAi.mData[3][2] + pVi.mData[2];
01429 
01430         return pAo;
01431     }
01432 
01433     /*
01434     *   KgeInvMult : Matrix Inverse Product
01435     */
01436     inline KgeMatrix& KgeInvMult(KgeMatrix& pMo, KM_CONST KgeMatrix& pMiA, KM_CONST KgeMatrix& pMiB)
01437     {
01438         return *(KgeMatrix *) KmMiM(pMo.mData, pMiA.mData, pMiB.mData);
01439     }
01440 
01441     /*
01442     *   KgeInvMult : Affine Matrix Inverse Product
01443     */
01444     inline KgeAMatrix& KgeInvMult(KgeAMatrix& pAo, KM_CONST KgeAMatrix& pAiA, KM_CONST KgeAMatrix& pAiB)
01445     {
01446         return *(KgeAMatrix *) KmAiA(pAo.mData, pAiA.mData, pAiB.mData);
01447     }
01448 
01449     /*
01450     *   KgeInvMult : Translation Matrix Inverse Product
01451     */
01452     inline KgeTMatrix& KgeInvMult(KgeTMatrix& pTo, KM_CONST KgeTMatrix& pTiA, KM_CONST KgeTMatrix& pTiB)
01453     {
01454         return *(KgeTMatrix *) KmTiT(pTo.mData, pTiA.mData, pTiB.mData);
01455     }
01456 
01457     /*
01458     *   KgeInvMult : Rotation Matrix Inverse Product
01459     */
01460     inline KgeRMatrix& KgeInvMult(KgeRMatrix& pRo, KM_CONST KgeRMatrix& pRiA, KM_CONST KgeRMatrix& pRiB)
01461     {
01462         return *(KgeRMatrix *) KmRiR(pRo.mData, pRiA.mData, pRiB.mData);
01463     }
01464 
01465     /*
01466     *   KgeInvMult : Scaling Matrix Inverse Product
01467     */
01468     inline KgeSMatrix& KgeInvMult(KgeSMatrix& pSo, KM_CONST KgeSMatrix& pSiA, KM_CONST KgeSMatrix& pSiB)
01469     {
01470         return *(KgeSMatrix *) KmSiS(pSo.mData, pSiA.mData, pSiB.mData);
01471     }
01472 
01474     //
01475     //  Matrix To Vector Decompositions
01476     //
01478 
01479     /*
01480     *   KgeSet : Translation Matrix To Vector
01481     */
01482     inline KgeTVector& KgeSet(KgeTVector& pVo, const KgeTMatrix& pTi)
01483     {
01484         return *(KgeTVector *) KmTtoV(pVo.mData, pTi.mData);
01485     }
01486 
01487     /*
01488     *   KgeSetXYZ : Rotation Matrix to XYZ Euler Vector
01489     */
01490     inline KgeRVector& KgeSetXYZ(KgeRVector& pVo, const KgeRMatrix& pRi)
01491     {    
01492         return *(KgeRVector *) KmRtoVXYZ(pVo.mData, pRi.mData);
01493     }
01494 
01495     /*
01496     *   KgeSetZYX : Rotation Matrix To ZYX Euler Vector
01497     */
01498     inline KgeRVector& KgeSetZYX(KgeRVector& pVo, const KgeRMatrix& pRi)
01499     {
01500         return *(KgeRVector *) KmRtoVZYX(pVo.mData, pRi.mData);
01501     }
01502 
01503     /*
01504     *   KgeSet : Rotation Matrix To Ordered Euler Vector
01505     */
01506     inline KgeRVector& KgeSet(KgeRVector& pVo, const KgeRMatrix& pRi, int pOrd)
01507     {
01508         return *(KgeRVector *) KmRtoVord(pVo.mData, pRi.mData, pOrd);
01509     }
01510 
01511     /*
01512     *   KgeSet : Rotation Matrix To Default Order Euler Vector
01513     */
01514     inline KgeRVector& KgeSet(KgeRVector& pVo, const KgeRMatrix& pRi)
01515     {
01516         return *(KgeRVector *) KmRtoV(pVo.mData, pRi.mData);
01517     }
01518 
01519     /*
01520     *   KgeSetXYZ : Quaternion to XYZ Euler Vector
01521     */
01522     inline KgeRVector& KgeSetXYZ(KgeRVector& pVo, const KgeQuaternion& pQi)
01523     {    
01524         return *(KgeRVector *) KmQtoVXYZ(pVo.mData, pQi.mData);
01525     }
01526 
01527     /*
01528     *   KgeSetZYX : Quaternion To ZYX Euler Vector
01529     */
01530     inline KgeRVector& KgeSetZYX(KgeRVector& pVo, const KgeQuaternion& pQi)
01531     {
01532         return *(KgeRVector *) KmQtoVZYX(pVo.mData, pQi.mData);
01533     }
01534 
01535     /*
01536     *   KgeSet : Quaternion To Ordered Euler Vector
01537     */
01538     inline KgeRVector& KgeSet(KgeRVector& pVo, const KgeQuaternion& pQi, const int pOrd)
01539     {
01540         return *(KgeRVector *) KmQtoVord(pVo.mData, pQi.mData, pOrd);
01541     }
01542 
01543     /*
01544     *   KgeSet : Quaternion To Default Order Euler Vector
01545     */
01546     inline KgeRVector& KgeSet(KgeRVector& pVo, const KgeQuaternion& pQi)
01547     {
01548         return *(KgeRVector *) KmQtoV(pVo.mData, pQi.mData);
01549     }
01550 
01551     /*
01552     *   KgeSet : Affine Matrix To Vector
01553     */
01554     inline void KgeSet(KgeTVector& pTo, KgeRVector& pRo, KgeSVector& pSo, const KgeAMatrix& pAi)
01555     {
01556         KmAtoV(pTo.mData, pRo.mData, pSo.mData, pAi.mData);
01557     }
01558 
01559     /*
01560     *   KgeSet : Affine Matrix To Ordered Vector
01561     */
01562     inline void KgeSet(KgeTVector& pTo, KgeRVector& pRo, KgeSVector& pSo, const KgeAMatrix& pAi, int pOrd)
01563     {
01564         KmAtoVord(pTo.mData, pRo.mData, pSo.mData, pAi.mData, pOrd);
01565     }
01566 
01567     /*
01568     *   KgeSet : Affine Matrix To Translation Vector
01569     */
01570     inline KgeTVector& KgeSet(KgeTVector& pTo, const KgeAMatrix& pAi)
01571     {
01572         return *(KgeTVector *) KmAtoVT(pTo.mData, pAi.mData);
01573     }
01574 
01575     /*
01576     *   KgeSet : Rotation Matrix To Direction Vector
01577     */
01578     inline KgeTVector& KgeSet(KgeTVector& pDo, const KgeRMatrix& pRi, const double pLength = 1.0)
01579     {
01580         return *(KgeTVector *) KmRtoD(pDo.mData, pRi.mData, pLength);
01581     }
01582 
01583     /*
01584     *   KgeSet : Affine Matrix To Rotation Vector
01585     */
01586     inline KgeRVector& KgeSet(KgeRVector& pRo, const KgeAMatrix& pAi)
01587     {
01588         return *(KgeRVector *) KmAtoVR(pRo.mData, pAi.mData);
01589     }
01590 
01591     /*
01592     *   KgeSet : Affine Matrix To Rotation Vector
01593     */
01594     inline KgeRVector& KgeSet(KgeRVector& pRo, const KgeAMatrix& pAi, int pOrd)
01595     {
01596         return *(KgeRVector *) KmAtoVRord(pRo.mData, pAi.mData, pOrd);
01597     }
01598 
01599     /*
01600     *   KgeSet : Affine Matrix To Translation Vector
01601     */
01602     inline KgeSVector& KgeSet(KgeSVector& pSo, const KgeAMatrix& pAi)
01603     {
01604         return *(KgeSVector *)KmAtoVS(pSo.mData, pAi.mData);
01605     }
01606 
01607 
01609     //
01610     //  Matrix Compositions
01611     //
01613 
01614     /*
01615     *   KgeSet : Translation Vector To Affine Matrix
01616     */
01617     inline KgeAMatrix& KgeSet(KgeAMatrix& pAo, const KgeTVector& pTi)
01618     {
01619         return *(KgeAMatrix *) KmVtoT(pAo.mData, pTi.mData);
01620     }
01621 
01622     /*
01623     *   KgeSet : Rotation Vector To Affine Matrix
01624     */
01625     inline KgeAMatrix& KgeSet(KgeAMatrix& pAo, const KgeRVector& pRi)
01626     {
01627         return *(KgeAMatrix *) KmVtoR(pAo.mData, pRi.mData);
01628     }
01629 
01630     /*
01631     *   KgeSet : Ordered Rotation Vector To Affine Matrix
01632     */
01633     inline KgeAMatrix& KgeSet(KgeAMatrix& pAo, const KgeRVector& pRi, const int pOrd)
01634     {
01635         return *(KgeAMatrix *) KmVIJKtoR(pAo.mData, pRi.mData, pOrd);
01636     }
01637 
01638     /*
01639     *   KgeSet : Vector To Affine Matrix
01640     */
01641     inline KgeAMatrix& KgeSet(KgeAMatrix& pAo, const KgeTVector& pTi, const KgeRVector& pRi)
01642     {
01643         (void) KmVtoT(pAo.mData, pTi.mData);
01644         return *(KgeAMatrix *) KmVtoR(pAo.mData, pRi.mData);
01645     }
01646 
01647     /*
01648     *   KgeSet : Vector To Affine Matrix
01649     */
01650     inline KgeAMatrix& KgeSet(KgeAMatrix& pAo, const KgeTVector& pTi, const KgeRMatrix& pRMi)
01651     {
01652         (void) KmRset(pAo.mData, pRMi.mData);
01653         return *(KgeAMatrix *) KmVtoT(pAo.mData, pTi.mData);
01654     }
01655 
01656     /*
01657     *   KgeSet : Vector To Affine Matrix
01658     */
01659     inline KgeAMatrix& KgeSet(KgeAMatrix& pAo, const KgeTVector& pTi, const KgeQuaternion& pQi)
01660     {
01661         (void) KmQtoR(pAo.mData, pQi.mData);
01662         return *(KgeAMatrix *) KmVtoT(pAo.mData, pTi.mData);
01663     }
01664 
01665 
01666     /*
01667     *   KgeSet : Vector To Affine Matrix
01668     */
01669     inline KgeAMatrix& KgeSet(KgeAMatrix& pAo, const KgeTVector& pTi, const KgeRVector& pRi, const int pOrd)
01670     {
01671         (void) KmVtoT(pAo.mData, pTi.mData);
01672         return *(KgeAMatrix *) KmVIJKtoR(pAo.mData, pRi.mData, pOrd);
01673     }
01674 
01675     /*
01676     *   KgeSet : Vector To Affine Matrix
01677     */
01678     inline KgeAMatrix& KgeSet(KgeAMatrix& pAo, const KgeTVector& pTi, const KgeRMatrix& pRMi, const KgeSVector& pSi)
01679     {
01680         (void) KmRS(pAo.mData, pRMi.mData, pSi.mData );
01681         return *(KgeAMatrix *) KmVtoT(pAo.mData, pTi.mData);
01682     }
01683 
01684     /*
01685     *   KgeSet : Vector To Affine Matrix
01686     */
01687     inline KgeAMatrix& KgeSet(KgeAMatrix& pAo, const KgeTVector& pTi, const KgeQuaternion& pQi, const KgeSVector& pSi)
01688     {
01689         (void) KmQtoR(pAo.mData, pQi.mData);
01690         (void) KgeMult( pAo, pAo, pSi );
01691         return *(KgeAMatrix *) KmVtoT(pAo.mData, pTi.mData);
01692     }
01693 
01694     /*
01695     *   KgeSet : Vector To Affine Matrix
01696     */
01697     inline KgeAMatrix& KgeSet(KgeAMatrix& pAo, const KgeTVector& pTi, const KgeRVector& pRi, const KgeSVector& pSi)
01698     {
01699         return *(KgeAMatrix *) KmVtoA(pAo.mData, pTi.mData, pRi.mData, pSi.mData);
01700     }
01701 
01702     /*
01703     *   KgeSet : Vector To Affine Matrix
01704     */
01705     inline KgeAMatrix& KgeSet(KgeAMatrix& pAo, const KgeTVector& pTi, const KgeRVector& pRi, const KgeSVector& pSi, const int pOrd)
01706     {
01707         return *(KgeAMatrix *) KmVtoAord(pAo.mData, pTi.mData, pRi.mData, pSi.mData, pOrd);
01708     }
01709 
01710     /*
01711     *   KgeSet : Vector To Translation Matrix
01712     */
01713     inline KgeTMatrix& KgeSet(KgeTMatrix& pTo, const KgeTVector& pVi)
01714     {
01715         return *(KgeTMatrix *) KmVtoT(pTo.mData, pVi.mData);
01716     }
01717 
01718     /*
01719     *   KgeSetXYZ : XYZ Euler Vector To Rotation Matrix
01720     */
01721     inline KgeRMatrix& KgeSetXYZ(KgeRMatrix& pRo, const KgeRVector& pVi)
01722     {
01723         return *(KgeRMatrix *) KmVXYZtoR(pRo.mData, pVi.mData);
01724     }
01725      
01726     /*
01727     *   KgeSetYZX : YZX Euler Vector To Rotation Matrix
01728     */
01729     inline KgeRMatrix& KgeSetYZX(KgeRMatrix& pRo, const KgeRVector& pVi)
01730     {
01731         return *(KgeRMatrix *) KmVYZXtoR(pRo.mData, pVi.mData);
01732     }
01733 
01734     /*
01735     *   KgeSetZXY : ZXY Euler Vector To Rotation Matrix
01736     */
01737     inline KgeRMatrix& KgeSetZXY(KgeRMatrix& pRo, const KgeRVector& pVi)
01738     {
01739         return *(KgeRMatrix *) KmVZXYtoR(pRo.mData, pVi.mData);
01740     }
01741 
01742     /*
01743     *   KgeSetXZY : XZY Euler Vector To Rotation Matrix
01744     */
01745     inline KgeRMatrix& KgeSetXZY(KgeRMatrix& pRo, const KgeRVector& pVi)
01746     {
01747         return *(KgeRMatrix *) KmVXZYtoR(pRo.mData, pVi.mData);
01748     }
01749      
01750     /*
01751     *   KgeSetYXZ : YXZ Euler Vector To Rotation Matrix
01752     */
01753     inline KgeRMatrix& KgeSetYXZ(KgeRMatrix& pRo, const KgeRVector& pVi)
01754     {
01755         return *(KgeRMatrix *) KmVYXZtoR(pRo.mData, pVi.mData);
01756     }
01757 
01758     /*
01759     *   KgeSetZYX : ZYX Euler Vector To Rotation Matrix
01760     */
01761     inline KgeRMatrix& KgeSetZYX(KgeRMatrix& pRo, const KgeRVector& pVi)
01762     {
01763         return *(KgeRMatrix *) KmVZYXtoR(pRo.mData, pVi.mData);
01764     }
01765 
01766     /*
01767     *   KgeSet : Ordered Euler Vector To Rotation Matrix
01768     */
01769     inline KgeRMatrix& KgeSet(KgeRMatrix& pRo, const KgeRVector& pVi, const int pOrd)
01770     {
01771         return *(KgeRMatrix *) KmVIJKtoR(pRo.mData, pVi.mData, pOrd);
01772     }
01773 
01774     /*
01775     *   KgeSet : Default Order Euler Vector To Rotation Matrix
01776     */
01777     inline KgeRMatrix& KgeSet(KgeRMatrix& pRo, const KgeRVector& pVi)
01778     {
01779         return *(KgeRMatrix *) KmVtoR(pRo.mData, pVi.mData);
01780     }
01781 
01782     /*
01783     *   KgeSet : Direction Vector To Rotation Matrix
01784     */
01785     inline KgeRMatrix& KgeSet(KgeRMatrix& pRo, const KgeTVector& pDi, double pRoll = 0.0)
01786     {
01787         return *(KgeRMatrix *) KmDtoR(pRo.mData, pDi.mData, pRoll);
01788     }
01789 
01790 
01791     /*
01792     *   KgeSet : Set Quaternion
01793     */
01794     inline KgeRMatrix& KgeSet(
01795         KgeRMatrix& pRo, const KgeQuaternion& pQi)
01796     {
01797         return *(KgeRMatrix *) KmQtoR(pRo.mData, pQi.mData);
01798     }
01799 
01800     /*
01801     *   KgeSet : Scalar to Scaling Matrix
01802     */
01803     inline KgeSMatrix& KgeSet(KgeSMatrix& pSo, const double pNi)
01804     {
01805         return *(KgeSMatrix *) KmNtoS(pSo.mData, pNi);
01806     }
01807 
01808     /*
01809     *   KgeSet : Vector To Scaling Matrix
01810     */
01811     inline KgeSMatrix& KgeSet(KgeSMatrix& pSo, const KgeSVector& pVi)
01812     {
01813         return *(KgeSMatrix *) KmVtoS(pSo.mData, pVi.mData);
01814     }
01815 
01817     //
01818     //  Class KgeTVector
01819     //
01821 
01822     inline KgeTVector::KgeTVector()
01823     {
01824         (void) Init();
01825         mData[3] = 1.0;
01826     }
01827 
01828     inline KgeTVector::KgeTVector(const double pN0, const double pN1, const double pN2)
01829     {
01830         mData[0] = pN0;
01831         mData[1] = pN1;
01832         mData[2] = pN2;
01833         mData[3] = 1.0;
01834     }
01835 
01836     inline KgeTVector::KgeTVector(const double *const pVi)
01837     {
01838         (void) operator=(pVi);
01839         mData[3] = 1.0;
01840     }
01841 
01842     inline KgeTVector::KgeTVector(const float *const pVi)
01843     {
01844         (void) operator=(pVi);
01845         mData[3] = 1.0;
01846     }
01847 
01848     inline KgeTVector::KgeTVector(const KgeTVector& pVi)
01849     {
01850         (void) operator=(pVi.mData);
01851         mData[3] = 1.0;
01852     }
01853 
01854     inline KgeTVector::KgeTVector(const KgeAMatrix& pAi)
01855     {
01856         (void) KgeSet(*this, pAi);
01857         mData[3] = 1.0;
01858     }
01859 
01860     inline KgeTVector::KgeTVector(const KgeTMatrix& pTi)
01861     {
01862         (void) KgeSet(*this, pTi);
01863         mData[3] = 1.0;
01864     }
01865 
01866     inline KgeTVector& KgeTVector::Init()
01867     {
01868         return mData[0] = mData[1] = mData[2] = 0.0, *this;
01869     }
01870 
01871     inline KgeTVector& KgeTVector::operator=(const double *const pVi)
01872     {
01873         mData[0] = pVi[0];
01874         mData[1] = pVi[1];
01875         mData[2] = pVi[2];
01876 
01877         return *this;
01878     }
01879 
01880     inline KgeTVector& KgeTVector::operator=(const float *const pVi)
01881     {
01882         mData[0] = pVi[0];
01883         mData[1] = pVi[1];
01884         mData[2] = pVi[2];
01885 
01886         return *this;
01887     }
01888 
01889 
01890     inline KgeTVector& KgeTVector::operator=(const KgeTVector& pVi)
01891     {
01892         return operator=(pVi.mData);
01893     }
01894     inline KgeTVector::operator const double *() const
01895     {
01896         return &mData[0];
01897     }
01898 
01899     inline bool KgeTVector::operator==(const KgeTVector& pVi) const
01900     {
01901         return (KgeCompare(*this, pVi) == 0); 
01902     }
01903 
01904     inline bool KgeTVector::operator!=(const KgeTVector& pVi) const
01905     {
01906         return (KgeCompare(*this, pVi) != 0); 
01907     }
01908 
01910     //
01911     //  Class KgeRGBAVector
01912     //
01914     inline KgeRGBAVector::KgeRGBAVector()
01915     {
01916         (void) Init();
01917     }
01918 
01919     inline KgeRGBAVector::KgeRGBAVector(const double pR, const double pG, const double pB, const double pA)
01920     {
01921         mData[0] = pR;
01922         mData[1] = pG;
01923         mData[2] = pB;
01924         mData[3] = pA;
01925     }
01926 
01927     inline KgeRGBAVector::KgeRGBAVector(const double *const pVi)
01928     {
01929         (void) operator=(pVi);
01930     }
01931 
01932     inline KgeRGBAVector::KgeRGBAVector(const KgeRGBAVector & pVi)
01933     {
01934         (void) operator=(pVi);
01935     }
01936 
01937     inline KgeRGBAVector& KgeRGBAVector::Init()
01938     {
01939         return mData[0] = mData[1] = mData[2] = mData[3] = 0.0, *this;
01940     }
01941 
01942     inline KgeRGBAVector& KgeRGBAVector::operator=(const double *const pVi)
01943     {
01944         mData[0] = pVi[0];
01945         mData[1] = pVi[1];
01946         mData[2] = pVi[2];
01947         mData[3] = pVi[3];
01948 
01949         return *this;
01950     }
01951 
01952 
01953     inline KgeRGBAVector & KgeRGBAVector::operator=(const KgeRGBAVector& pVi)
01954     {
01955         return operator=(pVi.mData);
01956     }
01957     inline KgeRGBAVector::operator const double *() const
01958     {
01959         return &mData[0];
01960     }
01961 
01962     inline bool KgeRGBAVector::operator==(const KgeRGBAVector& pVi) const
01963     {
01964         //return (KmVcmp(this->mData, pVi.mData, 0.0/*pThreshold*/) == 0); // Problem: no comparison for Alpha
01965         return (   (this->mData[0] == pVi.mData[0])
01966                 && (this->mData[1] == pVi.mData[1])
01967                 && (this->mData[2] == pVi.mData[2])
01968                 && (this->mData[3] == pVi.mData[3]));
01969     }
01970 
01971     inline bool KgeRGBAVector::operator!=(const KgeRGBAVector& pVi) const
01972     {
01973         //return (KmVcmp(this->mData, pVi.mData, 0.0/*pThreshold*/) != 0); // Problem: no comparison for Alpha
01974         return (   (this->mData[0] != pVi.mData[0])
01975                 || (this->mData[1] != pVi.mData[1])
01976                 || (this->mData[2] != pVi.mData[2])
01977                 || (this->mData[3] != pVi.mData[3]));
01978     }
01979 
01981     //
01982     //  Class KgeRGBVector
01983     //
01985     inline KgeRGBVector::KgeRGBVector()
01986     {
01987         (void) Init();
01988     }
01989 
01990     inline KgeRGBVector::KgeRGBVector(const double pR, const double pG, const double pB )
01991     {
01992         mData[0] = pR;
01993         mData[1] = pG;
01994         mData[2] = pB;
01995     }
01996 
01997     inline KgeRGBVector::KgeRGBVector(const double *const pVi)
01998     {
01999         (void) operator=(pVi);
02000     }
02001 
02002     inline KgeRGBVector::KgeRGBVector(const KgeRGBVector & pVi)
02003     {
02004         (void) operator=(pVi);
02005     }
02006 
02007     inline KgeRGBVector::KgeRGBVector(const KgeRGBAVector & pVi)
02008     {
02009         (void) operator=(pVi);
02010     }
02011 
02012 
02013     inline KgeRGBVector& KgeRGBVector::Init()
02014     {
02015         mData[0] = mData[1] = mData[2] = 0.0; mData[3] = 1.0;
02016         return *this;
02017     }
02018 
02019     inline KgeRGBVector& KgeRGBVector::operator=(const double *const pVi)
02020     {
02021         mData[0] = pVi[0];
02022         mData[1] = pVi[1];
02023         mData[2] = pVi[2];
02024 
02025         return *this;
02026     }
02027 
02028 
02029     inline KgeRGBVector & KgeRGBVector::operator=(const KgeRGBAVector& pVi)
02030     {
02031         return operator=(pVi.mData);
02032     }
02033 
02034     inline KgeRGBVector & KgeRGBVector::operator=(const KgeRGBVector& pVi)
02035     {
02036         return operator=(pVi.mData);
02037     }
02038 
02039 
02040     inline KgeRGBVector::operator const double *() const
02041     {
02042         return &mData[0];
02043     }
02044 
02045 
02046     inline bool KgeRGBVector::operator==(const KgeRGBVector& pVi) const
02047     {
02048         return (KmVcmp(this->mData, pVi.mData, 0.0/*pThreshold*/) == 0);
02049     }
02050 
02051     inline bool KgeRGBVector::operator!=(const KgeRGBVector& pVi) const
02052     {
02053         return (KmVcmp(this->mData, pVi.mData, 0.0/*pThreshold*/) != 0);
02054     }
02055 
02057     //
02058     //  Class KgeRVector
02059     //
02061 
02062     inline KgeRVector::KgeRVector()
02063     {
02064         (void) Init();
02065     }
02066 
02067     inline KgeRVector::KgeRVector(const double pN0, const double pN1, const double pN2)
02068     {
02069         (void) KmV(mData, pN0, pN1, pN2);
02070     }
02071 
02072     inline KgeRVector::KgeRVector(const double *const pVi)
02073     {
02074         (void) operator=(pVi);
02075     }
02076 
02077     inline KgeRVector::KgeRVector(const KgeRVector& pVi)
02078     {
02079         (void) operator=(pVi.mData);
02080     }
02081 
02082     inline KgeRVector::KgeRVector(const KgeAMatrix& pAi)
02083     {
02084         (void) KgeSet(*this, pAi);
02085     }
02086 
02087 
02088     inline KgeRVector::KgeRVector(const KgeRMatrix& pRi)
02089     {
02090         (void) KgeSet(*this, pRi);
02091     }
02092 
02093     inline KgeRVector::KgeRVector(const KgeRMatrix& pRi, const int pOrd)
02094     {
02095         (void) KgeSet(*this, pRi, pOrd);
02096     }
02097 
02098     inline KgeRVector::KgeRVector(const KgeQuaternion& pQi)
02099     {
02100         (void) KmQtoV(mData, pQi.mData);
02101     }
02102 
02103     inline KgeRVector::KgeRVector(const KgeQuaternion& pQi, const int pOrd)
02104     {
02105         (void) KmQtoVord(mData, pQi.mData, pOrd);
02106     }
02107 
02108     inline KgeRVector& KgeRVector::Init()
02109     {
02110         return mData[0] = mData[1] = mData[2] = 0.0, *this;
02111     }
02112 
02113     inline KgeRVector& KgeRVector::operator=(const double *const pVi)
02114     {
02115         return *(KgeRVector *) KmVset(mData, pVi);
02116     }
02117 
02118     inline KgeRVector& KgeRVector::operator=(const KgeRVector& pVi)
02119     {
02120         return operator=(pVi.mData);
02121     }
02122 
02123     inline KgeRVector::operator const double *() const
02124     {
02125         return &mData[0];
02126     }
02127 
02128     inline bool KgeRVector::operator==(const KgeRVector& pVi) const
02129     {
02130         return (KgeCompare(*this, pVi) == 0); 
02131     }
02132 
02133     inline bool KgeRVector::operator!=(const KgeRVector& pVi) const
02134     {
02135         return (KgeCompare(*this, pVi) != 0); 
02136     }
02137 
02139     //
02140     //  Class KgeSVector
02141     //
02143 
02144     inline KgeSVector::KgeSVector()
02145     {
02146         (void) Init();
02147     }
02148 
02149     inline KgeSVector::KgeSVector(const double pN)
02150     {
02151         KM_ASSERT(pN != 0.0, "Zero scaling factor used in KgeSVector constructor");
02152 
02153         (void) KmV(mData, pN, pN, pN);
02154     }
02155 
02156     inline KgeSVector::KgeSVector(const double pN0, const double pN1, const double pN2)
02157     {
02158         KM_ASSERT((pN0 != 0.0) && (pN1 != 0.0) && (pN2 != 0.0), "Zero scaling factor used in KgeSVector constructor");
02159 
02160         (void) KmV(mData, pN0, pN1, pN2);
02161     }
02162 
02163     inline KgeSVector::KgeSVector(const double *const pVi)
02164     {
02165         (void) operator=(pVi);
02166     }
02167 
02168     inline KgeSVector::KgeSVector(const KgeSVector& pVi)
02169     {
02170         (void) operator=(pVi.mData);
02171     }
02172 
02173     inline KgeSVector::KgeSVector(const KgeAMatrix& pAi)
02174     {
02175         KgeSet(*this, pAi);
02176     }
02177 
02178     inline KgeSVector::KgeSVector(const KgeSMatrix& pSi)
02179     {
02180         KmStoV(this->mData, pSi.mData);
02181     }
02182 
02183     inline KgeSVector& KgeSVector::Init()
02184     {
02185         return mData[0] = mData[1] = mData[2] = 1.0, *this;
02186     }
02187 
02188     inline KgeSVector& KgeSVector::operator=(const double *const pVi)
02189     {
02190         return *(KgeSVector *) KmVset(mData, pVi);
02191     }
02192 
02193     inline KgeSVector& KgeSVector::operator=(const KgeSVector& pVi)
02194     {
02195         return operator=(pVi.mData);
02196     }
02197 
02198     inline KgeSVector::operator const double *() const
02199     {
02200         return &mData[0];
02201     }
02202 
02203     inline bool KgeSVector::operator==(const KgeSVector& pVi) const
02204     {
02205         return (KgeCompare(*this, pVi) == 0); 
02206     }
02207     
02208     inline bool KgeSVector::operator!=(const KgeSVector& pVi) const
02209     {
02210         return (KgeCompare(*this, pVi) != 0); 
02211     }
02212 
02214     //
02215     //  Class KgeQuaternion
02216     //
02218 
02219     inline KgeQuaternion::KgeQuaternion()
02220     {
02221         (void) Init();
02222     }
02223 
02224     inline KgeQuaternion::KgeQuaternion(const double pX, const double pY, const double pZ, const double pW)
02225     {
02226         (void) KmQ(mData, pX, pY, pZ, pW);
02227     }
02228 
02229     inline KgeQuaternion::KgeQuaternion(const double *const pVi)
02230     {
02231         (void) operator=(pVi);
02232     }
02233 
02234     inline KgeQuaternion::KgeQuaternion(const KgeQuaternion& pVi)
02235     {
02236         (void) operator=(pVi.mData);
02237     }
02238 
02239     inline KgeQuaternion::KgeQuaternion(const KgeRVector& pVi)
02240     {
02241         (void) KmVtoQ(mData, pVi.mData);
02242     }
02243 
02244     inline KgeQuaternion::KgeQuaternion(const KgeRVector& pVi, const int pOrd)
02245     {
02246         (void) KmVIJKtoQ(mData, pVi.mData, pOrd);
02247     }
02248 
02249     inline KgeQuaternion::KgeQuaternion(const KgeAMatrix& pAi)
02250     {
02251         (void) KmRtoQ(mData, pAi.mData);
02252     }
02253 
02254     inline KgeQuaternion::KgeQuaternion(const KgeRMatrix& pRi)
02255     {
02256         (void) KmRtoQ(mData, pRi.mData);
02257     }
02258 
02259     inline KgeQuaternion& KgeQuaternion::Init()
02260     {
02261         return mData[0] = mData[1] = mData[2] = 0.0, mData[3] = 1.0, *this;
02262     }
02263 
02264     inline KgeQuaternion& KgeQuaternion::operator=(const double *const pVi)
02265     {
02266         return *(KgeQuaternion *) KmQset(mData, pVi);
02267     }
02268 
02269     inline KgeQuaternion& KgeQuaternion::operator=(const KgeQuaternion& pVi)
02270     {
02271         return operator=(pVi.mData);
02272     }
02273 
02274     inline KgeQuaternion::operator const double *() const
02275     {
02276         return &mData[0];
02277     }
02278 
02280     //
02281     //  Class KgeMatrix
02282     //
02284 
02285     inline KgeMatrix::KgeMatrix()
02286     {
02287         (void) Init();
02288     }
02289 
02290     inline KgeMatrix::KgeMatrix(const double (*const pMi)[4])
02291     {
02292         (void) operator=(pMi);
02293     }
02294 
02295     inline KgeMatrix::KgeMatrix(const KgeMatrix& pMi)
02296     {
02297         (void) operator=(pMi.mData);
02298     }
02299 
02300     inline KgeMatrix& KgeMatrix::Init()
02301     {
02302         return *(KgeMatrix *) KmId((double (*)[4]) mData);
02303     }
02304 
02305     inline KgeMatrix& KgeMatrix::operator=(const double (*const pMi)[4])
02306     {
02307         return *(KgeMatrix *) KmMset((double (*)[4]) mData, pMi);
02308     }
02309 
02310     inline KgeMatrix& KgeMatrix::operator=(const KgeMatrix& pMi)
02311     {
02312         return operator=(pMi.mData);
02313     }
02314 
02315     inline KgeMatrix::operator const double *() const
02316     {
02317         return &mData[0][0];
02318     }
02319 
02321     //
02322     //  Class KgeAMatrix
02323     //
02325 
02326     inline KgeAMatrix::KgeAMatrix()
02327     {
02328         (void) Init();
02329     }
02330 
02331     inline KgeAMatrix::KgeAMatrix(const KgeTVector& pTi)
02332     {
02333         (void) KmId((double (*)[4]) mData);
02334         (void) KmVtoT((double (*)[4]) mData, (const double *) pTi.mData);
02335     }
02336 
02337     inline KgeAMatrix::KgeAMatrix(const KgeRVector& pRi)
02338     {
02339         (void) KmId((double (*)[4]) mData);
02340         (void) KmVtoR((double (*)[4]) mData, (const double *) pRi.mData);
02341     }
02342 
02343     inline KgeAMatrix::KgeAMatrix(const KgeRVector& pRi, const int pOrd)
02344     {
02345         (void) KmId((double (*)[4]) mData);
02346         (void) KmVIJKtoR((double (*)[4]) mData, (const double *) pRi.mData, pOrd);
02347     }
02348 
02349     inline KgeAMatrix::KgeAMatrix(const KgeSVector& pSi)
02350     {
02351         (void) KmId((double (*)[4]) mData);
02352         (void) KmVtoS((double (*)[4]) mData, (const double *) pSi.mData);
02353     }
02354 
02355     inline KgeAMatrix::KgeAMatrix(const KgeTVector& pTi, const KgeRVector& pRi)
02356     {
02357         (void) KmId((double (*)[4]) mData);
02358         (void) KmVtoT((double (*)[4]) mData, (const double *) pTi.mData);
02359         (void) KmVtoR((double (*)[4]) mData, (const double *) pRi.mData);
02360     }
02361 
02362     inline KgeAMatrix::KgeAMatrix(const KgeTVector& pTi, const KgeRVector& pRi, const int pOrd)
02363     {
02364         (void) KmId((double (*)[4]) mData);
02365         (void) KmVtoT((double (*)[4]) mData, (const double *) pTi.mData);
02366         (void) KmVIJKtoR((double (*)[4]) mData, (const double *) pRi.mData, pOrd);
02367     }
02368 
02369     inline KgeAMatrix::KgeAMatrix(const KgeTVector& pTi, const KgeQuaternion& pQi)
02370     {
02371         (void) KmId((double (*)[4]) mData);
02372         (void) KmVtoT((double (*)[4]) mData, (const double *) pTi.mData);
02373         (void) KmQtoR((double (*)[4]) mData, (const double *) pQi.mData);
02374     }
02375 
02376     inline KgeAMatrix::KgeAMatrix(const KgeTVector& pTi, const KgeRVector& pRi, const KgeSVector& pSi)
02377     {
02378         (void) KmAinit((double (*)[4]) mData);
02379         (void) KmVtoA((double (*)[4]) mData, (const double *) pTi.mData, (const double *) pRi.mData, (const double *) pSi.mData);
02380     }
02381 
02382     inline KgeAMatrix::KgeAMatrix(const KgeTVector& pTi, const KgeRVector& pRi, const KgeSVector& pSi, const int pOrd)
02383     {
02384         (void) KmAinit((double (*)[4]) mData);
02385         (void) KmVtoAord((double (*)[4]) mData, (const double *) pTi.mData, (const double *) pRi.mData, (const double *) pSi.mData, pOrd);
02386     }
02387 
02388     inline KgeAMatrix::KgeAMatrix(const KgeTVector& pTi, const KgeQuaternion& pQi, const KgeSVector& pSi)
02389     {
02390         (void) KmId((double (*)[4]) mData);
02391         (void) KmVtoT((double (*)[4]) mData, (const double *) pTi.mData);
02392         (void) KmQtoR((double (*)[4]) mData, (const double *) pQi.mData);
02393         (void) KmVN((double *) mData[0], (double *) mData[0], pSi.mData[0]);
02394         (void) KmVN((double *) mData[1], (double *) mData[1], pSi.mData[1]);
02395         (void) KmVN((double *) mData[2], (double *) mData[2], pSi.mData[2]);
02396     }
02397 
02398     inline KgeAMatrix::KgeAMatrix(const double (*const pAi)[4])
02399     {
02400         (void) KmAinit((double (*)[4]) mData);
02401         (void) operator=(pAi);
02402     }
02403 
02404     inline KgeAMatrix::KgeAMatrix(const KgeAMatrix& pAi)
02405     {
02406         (void) KmMset((double (*)[4]) mData, pAi.mData);
02407     }
02408 
02409     inline KgeAMatrix& KgeAMatrix::Init()
02410     {
02411         return *(KgeAMatrix *) KmId((double (*)[4]) mData);
02412     }
02413 
02414     inline KgeAMatrix& KgeAMatrix::operator=(const double (*const pAi)[4])
02415     {
02416         return *(KgeAMatrix *) KmAset((double (*)[4]) mData, pAi);
02417     }
02418 
02419     inline KgeAMatrix& KgeAMatrix::operator=(const KgeAMatrix& pAi)
02420     {
02421         return operator=(pAi.mData);
02422     }
02423 
02424     inline KgeAMatrix::operator const double *() const
02425     {
02426         return &mData[0][0];
02427     }
02428 
02430     //
02431     //  Class KgeTMatrix
02432     //
02434 
02435     inline KgeTMatrix::KgeTMatrix()
02436     {
02437         (void) Init();
02438     }
02439 
02440     inline KgeTMatrix::KgeTMatrix(const double pX, const double pY, const double pZ)
02441     {
02442         (void) KmTinit(mData);
02443         (void) KmXYZtoT((double (*)[4]) mData, pX, pY, pZ);
02444     }
02445 
02446     inline KgeTMatrix::KgeTMatrix(const double (*const pTi)[4])
02447     {
02448         (void) KmTinit((double (*)[4]) mData);
02449         (void) operator=(pTi);
02450     }
02451 
02452     inline KgeTMatrix::KgeTMatrix(const KgeTMatrix& pTi)
02453     {
02454         (void) KmMset((double (*)[4]) mData, pTi.mData);
02455     }
02456 
02457     inline KgeTMatrix& KgeTMatrix::Init()
02458     {
02459         return *(KgeTMatrix *) KmId((double (*)[4]) mData);
02460     }
02461 
02462     inline KgeTMatrix& KgeTMatrix::operator=(const double (*const pTi)[4])
02463     {
02464         return *(KgeTMatrix *) KmTset((double (*)[4]) mData, pTi);
02465     }
02466 
02467     inline KgeTMatrix& KgeTMatrix::operator=(const KgeTMatrix& pTi)
02468     {
02469         return operator=(pTi.mData);
02470     }
02471 
02472     inline KgeTMatrix::operator const double *() const
02473     {
02474         return &mData[0][0];
02475     }
02476 
02478     //
02479     //  Class KgeRMatrix
02480     //
02482 
02483     inline KgeRMatrix::KgeRMatrix()
02484     {
02485         (void) Init();
02486     }
02487 
02488     inline KgeRMatrix::KgeRMatrix(const double pX, const double pY, const double pZ)
02489     {
02490         (void) KmRinit(mData);
02491         (void) KmXYZtoR((double (*)[4]) mData, pX, pY, pZ);
02492     }
02493 
02494     inline KgeRMatrix::KgeRMatrix(const double pI, const double pJ, const double pK, const int pOrd)
02495     {
02496         (void) KmRinit(mData);
02497         (void) KmIJKtoR((double (*)[4]) mData, pI, pJ, pK, pOrd);
02498     }
02499 
02500     inline KgeRMatrix::KgeRMatrix(const KgeRVector& pVi)
02501     {
02502         (void) KmRinit(mData);
02503         (void) KmVXYZtoR((double (*)[4]) mData, pVi.mData);
02504     }
02505 
02506     inline KgeRMatrix::KgeRMatrix(const KgeRVector& pVi, const int pOrd)
02507     {
02508         (void) KmRinit(mData);
02509         (void) KmVIJKtoR((double (*)[4]) mData, pVi.mData, pOrd);
02510     }
02511 
02512     inline KgeRMatrix::KgeRMatrix(const double (*const pRi)[4])
02513     {
02514         (void) KmRinit((double (*)[4]) mData);
02515         (void) operator=(pRi);
02516     }
02517 
02518     inline KgeRMatrix::KgeRMatrix(const KgeRMatrix& pRi)
02519     {
02520         (void) KmMset((double (*)[4]) mData, pRi.mData);
02521     }
02522 
02523     inline KgeRMatrix::KgeRMatrix(const KgeQuaternion& pQi)
02524     {
02525         (void) KmQtoR((double (*)[4]) mData, pQi.mData);
02526         (void) KmRinit((double (*)[4]) mData);
02527     }
02528 
02529     inline KgeRMatrix& KgeRMatrix::Init()
02530     {
02531         return *(KgeRMatrix *) KmId((double (*)[4]) mData);
02532     }
02533 
02534     inline KgeRMatrix& KgeRMatrix::operator=(const double (*const pRi)[4])
02535     {
02536         return *(KgeRMatrix *) KmRset((double (*)[4]) mData, pRi);
02537     }
02538 
02539     inline KgeRMatrix& KgeRMatrix::operator=(const KgeRMatrix& pRi)
02540     {
02541         return operator=(pRi.mData);
02542     }
02543 
02544     inline KgeRMatrix::operator const double *() const
02545     {
02546         return &mData[0][0];
02547     }
02548 
02550     //
02551     //  Class KgeSMatrix
02552     //
02554 
02555     inline KgeSMatrix::KgeSMatrix()
02556     {
02557         (void) Init();
02558     }
02559 
02560     inline KgeSMatrix::KgeSMatrix(const double pXYZ)
02561     {
02562         (void) KmSinit(mData);
02563         mData[0][0] = mData[1][1] = mData[2][2] = pXYZ;
02564     }
02565 
02566     inline KgeSMatrix::KgeSMatrix(const double pX, const double pY, const double pZ)
02567     {
02568         (void) KmSinit(mData);
02569         mData[0][0] = pX;
02570         mData[1][1] = pY;
02571         mData[2][2] = pZ;
02572     }
02573 
02574     inline KgeSMatrix::KgeSMatrix(const double (*const pSi)[4])
02575     {
02576         double S[3];
02577 
02578         (void) KmId(mData);
02579         (void) KmAtoS(S, pSi);
02580 
02581         mData[0][0] = S[0];
02582         mData[1][1] = S[1];
02583         mData[2][2] = S[2];
02584     }
02585 
02586     inline KgeSMatrix::KgeSMatrix(const KgeSMatrix& pSi)
02587     {
02588         (void) KmMset((double (*)[4]) mData, pSi.mData);
02589     }
02590 
02591     inline KgeSMatrix& KgeSMatrix::Init()
02592     {
02593         return *(KgeSMatrix *) KmId((double (*)[4]) mData);
02594     }
02595 
02596     inline KgeSMatrix& KgeSMatrix::operator=(const double (*const pSi)[4])
02597     {
02598         return *(KgeSMatrix *) KmSset((double (*)[4]) mData, pSi);
02599     }
02600 
02601     inline KgeSMatrix& KgeSMatrix::operator=(const KgeTMatrix& pSi)
02602     {
02603         return operator=(pSi.mData);
02604     }
02605 
02606     inline KgeSMatrix::operator const double *() const
02607     {
02608         return &mData[0][0];
02609     }
02610 
02612     //
02613     //  Class KgeLUMatrix
02614     //
02616 
02617     inline KgeLUMatrix::KgeLUMatrix()
02618     {
02619         (void) Init();
02620     }
02621 
02622     inline KgeLUMatrix::KgeLUMatrix(const KgeMatrix& pMi)
02623     {
02624         (void) KmMset((double (*)[4]) mData, (const double (*)[4]) pMi.mData);
02625         (void) KmLU(mData);
02626     }
02627 
02628     inline KgeLUMatrix& KgeLUMatrix::Init()
02629     {
02630         return *(KgeLUMatrix *) KmId((double (*)[4]) mData);
02631     }
02632 
02633     inline KgeLUMatrix::operator const double *() const
02634     {
02635         return &mData[0][0];
02636     }
02637 
02639     //
02640     //  Class KgeXForm
02641     //
02643 
02644     inline KgeXForm::KgeXForm()
02645     {
02646         mF = FLAG_A;
02647     }
02648 
02649     inline KgeXForm::KgeXForm(KgeXForm& pXi)
02650     {
02651         (void) operator=(pXi);
02652     }
02653 
02654     inline KgeXForm::KgeXForm(const KgeTVector& pTi) : mM(pTi)
02655     {
02656         mF = FLAG_A;
02657     }
02658 
02659     inline KgeXForm::KgeXForm(const KgeRVector& pRi) : mR(pRi)
02660     {
02661         mF = FLAG_R;
02662     }
02663 
02664     inline KgeXForm::KgeXForm(const KgeRVector& pRi, const int pOrd) : mM(pRi, pOrd)
02665     {
02666         mF = FLAG_M;
02667     }
02668 
02669     inline KgeXForm::KgeXForm(const KgeTVector& pTi, const KgeRVector& pRi) : mM(pTi, pRi), mR(pRi)
02670     {
02671         mF = FLAG_M | FLAG_R;
02672     }
02673 
02674     inline KgeXForm::KgeXForm(const KgeTVector& pTi, const KgeRVector& pRi, const int pOrd) : mM(pTi, pRi, pOrd)
02675     {
02676         mF = FLAG_M;
02677     }
02678 
02679     inline KgeXForm::KgeXForm(const KgeTVector& pTi, const KgeQuaternion& pQi) : mM(pTi, pQi), mQ(pQi)
02680     {
02681         mF = FLAG_M | FLAG_Q;
02682     }
02683 
02684     inline KgeXForm::KgeXForm(const double (*const pMi)[4]) : mM(pMi)
02685     {
02686         mF = FLAG_M;
02687     }
02688 
02689     inline KgeXForm::KgeXForm(const KgeAMatrix& pAi) : mM(pAi)
02690     {
02691         mF = FLAG_M;
02692     }
02693 
02694     inline KgeXForm::~KgeXForm()
02695     {
02696     }
02697 
02698     inline KgeXForm& KgeXForm::Init()
02699     {
02700         return mF = FLAG_A, mM.Init(), mR.Init(), mQ.Init(), *this;
02701     }
02702 
02703     inline KgeXForm& KgeXForm::operator=(const KgeXForm& pXi)
02704     {
02705         return *(KgeXForm *) memcpy((void *) this, (void *) &pXi, sizeof(KgeXForm));
02706     }
02707 
02708     inline KgeXForm& KgeXForm::operator=(const KgeAMatrix& pAi)
02709     {
02710         return SetM(pAi), *this;
02711     }
02712 
02713     inline KgeXForm& KgeXForm::operator=(const KgeRMatrix& pRi)
02714     {
02715         return SetM((KgeAMatrix&) pRi), *this;
02716     }
02717 
02718     inline KgeXForm& KgeXForm::operator=(const KgeTMatrix& pTi)
02719     {
02720         return SetM((KgeAMatrix&) pTi), *this;
02721     }
02722 
02723     inline KgeXForm& KgeXForm::operator=(const double (*const pM)[4])
02724     {
02725         return SetM((KgeAMatrix&) pM), *this;
02726     }
02727 
02728     inline const KgeAMatrix& KgeXForm::GetM()
02729     {
02730         if(mF & FLAG_M) {
02731             return mM;
02732         }
02733         if(mF & FLAG_Q) {
02734             (void) KgeSet((KgeRMatrix&) mM, mQ);
02735         } else {
02736             (void) KgeSet((KgeRMatrix&) mM, mR);
02737         }
02738         return mF |= FLAG_M, mM;
02739     }
02740 
02741     inline const KgeTVector& KgeXForm::GetT() const
02742     {
02743         return *(KgeTVector *) mM.mData[3];
02744     }
02745 
02746     inline const KgeTVector& KgeXForm::GetI()
02747     {
02748         return *(KgeTVector *) mM.mData[0];
02749     }
02750 
02751     inline const KgeTVector& KgeXForm::GetJ()
02752     {
02753         return *(KgeTVector *) mM.mData[1];
02754     }
02755 
02756     inline const KgeTVector& KgeXForm::GetK()
02757     {
02758         return *(KgeTVector *) mM.mData[2];
02759     }
02760 
02761     inline double KgeXForm::GetTX() const
02762     {
02763         return mM.mData[3][0];
02764     }
02765 
02766     inline double KgeXForm::GetTY() const
02767     {
02768         return mM.mData[3][1];
02769     }
02770 
02771     inline double KgeXForm::GetTZ() const
02772     {
02773         return mM.mData[3][2];
02774     }
02775 
02776     inline const KgeRVector& KgeXForm::GetR()
02777     {
02778         if(mF & FLAG_R) {
02779             return mR;
02780         }
02781         if(mF & FLAG_M) {
02782             (void) KgeSet(mR, (KgeRMatrix&) mM);
02783         } else {
02784             (void) KgeSet(mR, mQ);
02785         }
02786         return mF |= FLAG_R, mR;
02787     }
02788 
02789     inline const KgeRVector& KgeXForm::GetR(KgeRVector& pVo, const int pOrd)
02790     {
02791         if(pOrd == KM_EULER_XYZ) {
02792             return KgeSet(pVo, GetR());
02793         } else {
02794             return KgeSet(pVo, (KgeRMatrix&) GetM(), pOrd);
02795         }
02796     }
02797 
02798     inline double KgeXForm::GetRX()
02799     {
02800         if(mF & FLAG_R) {
02801             return mR.mData[0];
02802         }
02803         if(mF & FLAG_M) {
02804             (void) KgeSet(mR, (KgeRMatrix&) mM);
02805         } else {
02806             (void) KgeSet(mR, mQ);
02807         }
02808         return mF |= FLAG_R, mR.mData[0];
02809     }
02810 
02811     inline double KgeXForm::GetRY()
02812     {
02813         if(mF & FLAG_R) {
02814             return mR.mData[1];
02815         }
02816         if(mF & FLAG_M) {
02817             (void) KgeSet(mR, (KgeRMatrix&) mM);
02818         } else {
02819             (void) KgeSet(mR, mQ);
02820         }
02821         return mF |= FLAG_R, mR.mData[1];
02822     }
02823 
02824     inline double KgeXForm::GetRZ()
02825     {
02826         if(mF & FLAG_R) {
02827             return mR.mData[2];
02828         }
02829         if(mF & FLAG_M) {
02830             (void) KgeSet(mR, (KgeRMatrix&) mM);
02831         } else {
02832             (void) KgeSet(mR, mQ);
02833         }
02834         return mF |= FLAG_R, mR.mData[2];
02835     }
02836 
02837     inline const KgeQuaternion& KgeXForm::GetQ()
02838     {
02839         if(mF & FLAG_Q) {
02840             return mQ;
02841         }
02842         if(mF & FLAG_M) {
02843             (void) KgeSet(mQ, (KgeRMatrix&) mM);
02844         } else {
02845             (void) KgeSet((KgeRMatrix&)mM, mR);
02846             (void) KgeSet(mQ, (KgeRMatrix&) mM);
02847             mF |= FLAG_M;
02848         }
02849         return mF |= FLAG_Q, mQ;
02850     }
02851 
02852     inline const KgeAMatrix& KgeXForm::SetM(const KgeAMatrix& pM)
02853     {
02854         return mF = FLAG_M, &mM != &pM ? KgeSet(mM, pM), pM : pM;
02855     }
02856 
02857     inline const KgeTVector& KgeXForm::SetT(const KgeTVector& pT)
02858     {
02859         return KgeSet(*(KgeTVector *) mM.mData[3], pT), pT;
02860     }
02861 
02862 
02863     // Function must be verified before it is use
02864     /*
02865     inline const KgeTVector& KgeXForm::SetT(const double pVx, const double pVy, const double pVz)
02866     {
02867         return mM.mData[3][0] = pVx, mM.mData[3][1] = pVy, mM.mData[3][2] = pVz, mM.mData[3];
02868     }
02869     */
02870 
02871     inline double KgeXForm::SetTX(const double pVx)
02872     {
02873         return mM.mData[3][0] = pVx;
02874     }
02875 
02876     inline double KgeXForm::SetTY(const double pVy)
02877     {
02878         return mM.mData[3][1] = pVy;
02879     }
02880 
02881     inline double KgeXForm::SetTZ(const double pVz)
02882     {
02883         return mM.mData[3][2] = pVz;
02884     }
02885 
02886     inline const KgeRVector& KgeXForm::SetR(const KgeRVector& pR)
02887     {
02888         return mF = FLAG_R, KgeSet(mR, pR);
02889     }
02890 
02891     inline const KgeRVector& KgeXForm::SetR(const KgeRVector& pR, const int pOrd)
02892     {
02893         return mF = FLAG_M, KgeSet((KgeRMatrix&) mM, pR, pOrd), pR;
02894     }
02895 
02896     inline const KgeRVector& KgeXForm::SetR(const double pVx, const double pVy, const double pVz)
02897     {
02898         return mF = FLAG_R, mR.mData[0] = pVx, mR.mData[1] = pVy, mR.mData[2] = pVz, mR;
02899     }
02900 
02901     inline double KgeXForm::SetRX(const double pVx)
02902     {
02903         return mF = FLAG_R, mR.mData[0] = pVx;
02904     }
02905 
02906     inline double KgeXForm::SetRY(const double pVy)
02907     {
02908         return mF = FLAG_R, mR.mData[1] = pVy;
02909     }
02910 
02911     inline double KgeXForm::SetRZ(const double pVz)
02912     {
02913         return mF = FLAG_R, mR.mData[2] = pVz;
02914     }
02915 
02916     inline const KgeQuaternion& KgeXForm::SetQ(const KgeQuaternion& pQ)
02917     {
02918         return mF = FLAG_Q, KgeSet(mQ, pQ);
02919     }
02920 
02921     inline KgeXForm& KgeXForm::operator*=(const KgeXForm& pXi)
02922     {
02923         return KgeMult(*this, (KgeXForm&) pXi, *this);
02924     }
02925 
02926     inline KgeXForm& KgeXForm::operator/=(const KgeXForm& pXi)
02927     {
02928         return KgeInvMult(*this, (KgeXForm&) pXi, *this);
02929     }
02930 
02931     /*
02932     *   KgeId : Transform Set
02933     */
02934     inline KgeXForm& KgeIdentity(KgeXForm& pXo)
02935     {
02936         return pXo.Init();
02937     }
02938 
02939     /*
02940     *   KgeSet : Transform Set
02941     */
02942     inline KgeXForm& KgeSet(KgeXForm& pXo, const KgeXForm& pXi)
02943     {
02944         return pXo = pXi;
02945     }
02946 
02947     /*
02948     *   KgeSet : Transform Set
02949     */
02950     inline KgeXForm& KgeSet(KgeXForm& pXo, const KgeTVector& pTi, const KgeRVector& pRi)
02951     {
02952         return pXo.SetT(pTi), pXo.SetR(pRi), pXo;
02953     }
02954 
02955     /*
02956     *   KgeMult : Transform Product
02957     */
02958     inline KgeXForm& KgeMult(KgeXForm& pTo, KgeXForm& pTiA, KgeXForm& pTiB)
02959     {
02960         return pTo.mF = KgeXForm::FLAG_M, (KgeXForm&) KgeMult(pTo.mM, pTiA.GetM(), pTiB.GetM());
02961     }
02962 
02963     /*
02964     *   KgeInvMult : Transform Inverse Product
02965     */
02966     inline KgeXForm& KgeInvMult(KgeXForm& pTo, KgeXForm& pTiA, KgeXForm& pTiB)
02967     {
02968         return pTo.mF = KgeXForm::FLAG_M, (KgeXForm&) KgeInvMult(pTo.mM, pTiA.GetM(), pTiB.GetM());
02969     }
02970 
02971     /*
02972     // Helpers for Number Validation
02973     */
02974     inline bool KgeValidate(double *pVector)
02975     {
02976         return  ( kValidate(pVector[0]) == pVector[0] ) &&
02977                 ( kValidate(pVector[1]) == pVector[1] ) &&
02978                 ( kValidate(pVector[2]) == pVector[2] ) &&
02979                 ( kValidate(pVector[3]) == pVector[3] );
02980     }
02981 
02982     inline bool KgeValidate(KgeVector &pVectorToValidate)
02983     {
02984         return  KgeValidate(pVectorToValidate.mData);
02985     }
02986 
02987     inline bool KgeValidate(KgeMatrix &pMatrixToValidate)
02988     {
02989         return  KgeValidate(pMatrixToValidate.mData[0]) && KgeValidate(pMatrixToValidate.mData[1]) && 
02990                 KgeValidate(pMatrixToValidate.mData[2]) && KgeValidate(pMatrixToValidate.mData[3]);
02991     }
02992 
02993 
02995     //
02996     //  Class KRect
02997     //
02999 
03000     inline KRect::KRect()
03001     : mX(0), mY(0), mW(0), mH(0)
03002     {
03003     }
03004 
03005 
03006     inline KRect::KRect(int pX, int pY, int pW, int pH)
03007     : mX(pX), mY(pY), mW(pW), mH(pH)
03008     {
03009     }
03010 
03011     inline int KRect::GetLeft()const
03012     {
03013         return mX;
03014     }
03015     
03016     inline int KRect::GetRight()const
03017     {
03018         return mX + mW;
03019     }
03020     
03021     inline int KRect::GetBottom()const
03022     {
03023         return mY + mH;
03024     }
03025     
03026     inline int KRect::GetTop()const
03027     {
03028         return mY;
03029     }
03030 
03031     inline void KRect::Union(const KRect& pRect)
03032     {
03033         int lX2, lY2;
03034         int lX3, lY3;
03035 
03036         lX2 = mX + mW;
03037         lY2 = mY + mH;
03038 
03039         lX3 = pRect.mX + pRect.mW;
03040         lY3 = pRect.mY + pRect.mH;
03041 
03042         if (pRect.mX < mX)
03043             mX = pRect.mX;
03044 
03045         if (pRect.mY < mY)
03046             mY = pRect.mY;
03047 
03048         if (lX3 > lX2)
03049             lX2 = lX3;
03050 
03051         if (lY3 > lY2)
03052             lY2 = lY3;
03053 
03054         mW = lX2 - mX;
03055         mH = lY2 - mY;
03056 
03057     }
03058 
03059     inline bool KRect::PointInside(int pX, int pY)
03060     {
03061         if (pX >= mX && pX <= (mX + mW))
03062             if (pY >= mY && pY <= (mY + mH))
03063             {
03064                 return true;
03065             }
03066 
03067         return false;
03068     }
03069 
03070     inline bool KRect::HasAnIntersection(const KRect& pRect) const
03071     {
03072         if ( ((mX + mW) > pRect.mX) && (mX < (pRect.mX + pRect.mW)) )
03073         {
03074             // rectanbles intersect on X, check Y
03075             if ( ((mY + mH) > pRect.mY) && (mY < (pRect.mY + pRect.mH)) )
03076             {
03077                 return true;
03078             }
03079         }
03080 
03081         return false;
03082     }
03083 
03084     // StrictlyContains: pRect is inside this Rect and does not touch any side.
03085     inline bool KRect::StrictlyContains(const KRect& pRect) const
03086     {
03087         if  (  ( mX < pRect.mX) && ((mX + mW) > (pRect.mX + pRect.mW))      // Contains in X
03088             && ( mY < pRect.mY) && ((mY + mH) > (pRect.mY + pRect.mH)) )    // Contains in Y
03089         {
03090             return true;
03091         }
03092         return false;
03093     }
03094 
03095     // StrictlyIntersects: pRect crosses or overlaps one of the sides of this Rect.
03096     inline bool KRect::StrictlyIntersects(const KRect& pRect) const
03097     {
03098         if ( ((mX + mW) >= pRect.mX) && (mX <= (pRect.mX + pRect.mW)) )     // Intersect in X
03099         {
03100             if ( ((mY + mH) >= pRect.mY) && (mY <= (pRect.mY + pRect.mH)) ) // Intersect in Y
03101             {
03102                 if (!StrictlyContains(pRect) && !pRect.StrictlyContains(*this))
03103                 {
03104                     return true;
03105                 }
03106             }
03107         }
03108         return false;
03109     }
03110 
03111     inline void KRect::Intersection(const KRect& pRect)
03112     {
03113         int lNx, lNy;
03114         int lNw, lNh;
03115         
03116         // take the biggest left
03117         if (pRect.mX > mX)
03118             lNx = pRect.mX;
03119         else
03120             lNx = mX;
03121 
03122         // take the smallest right
03123         if ( (pRect.mX + pRect.mW) < (mX + mW))
03124             lNw = pRect.mX + pRect.mW - lNx;
03125         else
03126             lNw = mX + mW - lNx;
03127 
03128         // take the biggest top
03129         if (pRect.mY > mY)
03130             lNy = pRect.mY;
03131         else
03132             lNy = mY;
03133 
03134         // take the smallest bottom
03135         if ( (pRect.mY + pRect.mH) < (mY + mH))
03136             lNh = pRect.mY + pRect.mH - lNy;
03137         else
03138             lNh = mY + mH - lNy;
03139 
03140         mX = lNx;
03141         mY = lNy;
03142         mW = lNw;
03143         mH = lNh;
03144     }
03145 
03146 
03147     inline void KRect::Translate(int pDeltaX, int pDeltaY)
03148     {
03149         mX += pDeltaX;
03150         mY += pDeltaY;
03151     }
03152 
03153 #include <fbxfilesdk/fbxfilesdk_nsend.h>
03154 
03155 #endif // FBXFILESDK_COMPONENTS_KBASELIB_KMATH_KGEOM_H
03156