00001
00002
00012
00013
00014 #if (_MSC_VER > 1000) || defined(SGI_COMPILER)
00015 #pragma once
00016 #endif
00017
00018
00019
00020
00021
00022 #ifndef _XFOMAT_H_
00023 #define _XFOMAT_H_
00024
00025
00026
00027
00028 #include "SIBCMathLib.h"
00029 #include "SIBCMatrix.h"
00030
00031
00032
00033 #define _3D_NB_BITS_RESERVED_BY_XFOMAT (unsigned char)( 3 )
00034
00035
00036
00037
00038
00057 class XSICOREEXPORT CSIBCXfoMatd : private CSIBCMatrix44d
00058 {
00059
00060 public:
00061
00062
00063
00064
00069 CSIBCXfoMatd( void );
00070
00082 CSIBCXfoMatd(
00083 const CSIBCVector4Dd& in_vct0,
00084 const CSIBCVector4Dd& in_vct1,
00085 const CSIBCVector4Dd& in_vct2,
00086 const CSIBCVector4Dd& in_vct3,
00087 const bool in_bAreRows = true );
00088
00108 CSIBCXfoMatd(
00109 const double in_dA00, const double in_dA01, const double in_dA02, const double in_dA03,
00110 const double in_dA10, const double in_dA11, const double in_dA12, const double in_dA13,
00111 const double in_dA20, const double in_dA21, const double in_dA22, const double in_dA23,
00112 const double in_dA30, const double in_dA31, const double in_dA32, const double in_dA33 );
00113
00114
00115
00116
00117
00124 double Get( const int in_nRow, const int in_nCol ) const;
00125
00132 const double * GetArray() const;
00133
00134
00135
00136
00137
00148 CSIBCXfoMatd& Set( int in_nRow, int in_nCol, const double in_dVal );
00149
00159 CSIBCXfoMatd& Set( double in_dVal[4][4] );
00160
00166 CSIBCXfoMatd& Set( double in_dVal[3][3] );
00167
00176 CSIBCXfoMatd& Set( const CSIBCMatrix44d& in_mat );
00177
00187 CSIBCXfoMatd& Set( const CSIBCMatrix33d& in_mat );
00188
00197 CSIBCXfoMatd& Set( const CSIBCXfoMatd& in_mat );
00198
00207 CSIBCXfoMatd& Set( const CSIBCRotMatd& in_mat );
00208
00218 CSIBCXfoMatd& SetWithTranspose( const CSIBCRotMatd& in_mat );
00219
00229 CSIBCXfoMatd& SetRow( const int in_nRow, const CSIBCVector4Dd& in_vct );
00230
00242 CSIBCXfoMatd& SetRow( const int in_nRow, double in_dA0, double in_dA1, double in_dA2, double in_dA3 );
00243
00253 CSIBCXfoMatd& SetCol( const int in_nCol, const CSIBCVector4Dd& in_vct );
00254
00266 CSIBCXfoMatd& SetCol( const int in_nCol, double in_dA0, double in_dA1, double in_dA2, double in_dA3 );
00267
00272 CSIBCXfoMatd& SetIdentity( void );
00273
00274
00275
00276
00277
00289 friend bool AreAlmostEqual( const CSIBCXfoMatd& in_mat1,
00290 const CSIBCXfoMatd& in_mat2,
00291 const double in_dEpsilon = HEXA_EPS );
00292
00301 bool operator ==( const CSIBCMatrix44d& in_mat ) const;
00302
00311 bool operator !=( const CSIBCMatrix44d& in_mat ) const;
00312
00313
00314
00315
00316
00325 CSIBCXfoMatd& Mul( const CSIBCXfoMatd& in_mat1, const CSIBCXfoMatd& in_mat2 );
00326
00334 CSIBCXfoMatd& Mul( const CSIBCXfoMatd& in_mat );
00335
00344 CSIBCXfoMatd& Mul( const CSIBCXfoMatd& in_xfomat, const CSIBCRotMatd& in_rotmat );
00345
00354 CSIBCXfoMatd& Mul( const CSIBCRotMatd& in_rotmat, const CSIBCXfoMatd& in_xfomat );
00355
00356
00367 CSIBCXfoMatd& MulTransByReg( const CSIBCRotMatd& in_rotmat,
00368 const CSIBCXfoMatd& in_xfomat );
00369
00375 double GetDet( void ) const;
00376
00382 double GetDet33( void ) const;
00383
00389 double GetTrace( void ) const;
00390
00396 CSIBCXfoMatd& Transpose( const CSIBCXfoMatd& in_mat );
00397
00402 CSIBCXfoMatd& Transpose( void );
00403
00410 bool Invert( const CSIBCXfoMatd& in_mat );
00411
00417 bool Invert( void );
00418
00425 CSIBCVector3Dd& GetTranslation( CSIBCVector3Dd& out_vctTrs ) const;
00426
00433 CSIBCXfoMatd& SetTranslation( const CSIBCVector3Dd& in_vctTrs );
00434
00441 CSIBCXfoMatd& AddTranslation( const CSIBCVector3Dd& in_vctTrs );
00442
00450 CSIBCRotMatd& GetRotation( CSIBCRotMatd& out_matRot ) const;
00451
00459 CSIBCRotationd& GetRotation( CSIBCRotationd& out_rot ) const;
00460
00467 CSIBCXfoMatd& SetRotation( const CSIBCRotMatd& in_matRot );
00468
00475 CSIBCXfoMatd& AddRotation( const CSIBCRotMatd& in_matRot );
00476
00483 CSIBCVector3Dd& GetScaling( CSIBCVector3Dd& out_vctScl ) const;
00484
00491 CSIBCXfoMatd& SetScaling( const CSIBCVector3Dd& in_vctScl );
00492
00502 CSIBCXfoMatd& AddScaling( const CSIBCVector3Dd& in_vctScl, bool in_bPreScaling = true );
00503
00512 void SetScalingAndRotation( const CSIBCVector3Dd& in_vctScl, CSIBCRotationd& in_rot );
00513
00522 void GetScalingAndRotation( CSIBCVector3Dd& out_vctScl, CSIBCRotationd& out_rot ) const;
00523
00530 void GetAffineDecomposition ( CSIBCRotMatd& out_sclRot, CSIBCXfoMatd& out_matSRT ) const;
00531
00539 void GetSmartDecomposition ( CSIBCVector3D& out_Scale, CSIBCVector3D& out_Rotate, CSIBCVector3D& out_Trans ) const;
00540
00541
00542 protected:
00543
00544
00545
00546 enum {
00547 _3D_X_NEGATIVE = (unsigned char)( 1 << (_3D_NB_BITS_RESERVED_BY_MAT44 + 0) ),
00548 _3D_Y_NEGATIVE = (unsigned char)( 1 << (_3D_NB_BITS_RESERVED_BY_MAT44 + 1) ),
00549 _3D_Z_NEGATIVE = (unsigned char)( 1 << (_3D_NB_BITS_RESERVED_BY_MAT44 + 2) ),
00550 _3D_ALLAXES_NEGATIVE_MASK = (unsigned char)( _3D_X_NEGATIVE | _3D_Y_NEGATIVE | _3D_Z_NEGATIVE ),
00551 };
00552
00553
00554 private:
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566 CSIBCXfoMatd( const CSIBCMatrix44d & );
00567 CSIBCXfoMatd( const CSIBCMatrix33d& in_mat );
00568
00569
00570 CSIBCXfoMatd( const CSIBCXfoMatd& in_mat );
00571 CSIBCXfoMatd& operator =( const CSIBCXfoMatd& in_mat );
00572
00573
00574 void SetSclSignBits( const CSIBCVector3Dd &in_vctScl );
00575 void XORSclSignBits( const CSIBCVector3Dd &in_vctScl );
00576
00577 void SetSclSignBits( const unsigned char in_SclBits );
00578 void XORSclSignBits( const unsigned char in_Bits1, const unsigned char in_Bits2 );
00579 unsigned char GetSclSignBits( ) const;
00580 void ClearSclSignBits();
00581 bool IsSclAxisNegative( int in_axe ) const;
00582 };
00583 typedef CSIBCXfoMatd* LP3DXFOMAT;
00584 typedef const CSIBCXfoMatd* LPC3DXFOMAT;
00585
00586 #endif