00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if (_MSC_VER > 1000) || defined(SGI_COMPILER)
00025 #pragma once
00026 #endif
00027
00028
00029
00030
00031
00032 #ifndef _XFOMAT_H_
00033 #define _XFOMAT_H_
00034
00035
00036
00037
00038 #include "SIBCMathLib.h"
00039 #include "SIBCMatrix.h"
00040
00041
00042
00043 #define _3D_NB_BITS_RESERVED_BY_XFOMAT (unsigned char)( 3 )
00044
00045
00046
00047
00048
00050
00066 class XSICOREEXPORT CSIBCXfoMatd : private CSIBCMatrix44d
00067 {
00068
00069 public:
00070
00071
00072
00073
00078 CSIBCXfoMatd( void );
00079
00091 CSIBCXfoMatd(
00092 const CSIBCVector4Dd& in_vct0,
00093 const CSIBCVector4Dd& in_vct1,
00094 const CSIBCVector4Dd& in_vct2,
00095 const CSIBCVector4Dd& in_vct3,
00096 const bool in_bAreRows = true );
00097
00117 CSIBCXfoMatd(
00118 const double in_dA00, const double in_dA01, const double in_dA02, const double in_dA03,
00119 const double in_dA10, const double in_dA11, const double in_dA12, const double in_dA13,
00120 const double in_dA20, const double in_dA21, const double in_dA22, const double in_dA23,
00121 const double in_dA30, const double in_dA31, const double in_dA32, const double in_dA33 );
00122
00123
00124
00125
00126
00133 double Get( const int in_nRow, const int in_nCol ) const;
00134
00141 const double * GetArray() const;
00142
00143
00144
00145
00146
00157 CSIBCXfoMatd& Set( int in_nRow, int in_nCol, const double in_dVal );
00158
00168 CSIBCXfoMatd& Set( double in_dVal[4][4] );
00169
00175 CSIBCXfoMatd& Set( double in_dVal[3][3] );
00176
00185 CSIBCXfoMatd& Set( const CSIBCMatrix44d& in_mat );
00186
00196 CSIBCXfoMatd& Set( const CSIBCMatrix33d& in_mat );
00197
00206 CSIBCXfoMatd& Set( const CSIBCXfoMatd& in_mat );
00207
00216 CSIBCXfoMatd& Set( const CSIBCRotMatd& in_mat );
00217
00227 CSIBCXfoMatd& SetWithTranspose( const CSIBCRotMatd& in_mat );
00228
00238 CSIBCXfoMatd& SetRow( const int in_nRow, const CSIBCVector4Dd& in_vct );
00239
00251 CSIBCXfoMatd& SetRow( const int in_nRow, double in_dA0, double in_dA1, double in_dA2, double in_dA3 );
00252
00262 CSIBCXfoMatd& SetCol( const int in_nCol, const CSIBCVector4Dd& in_vct );
00263
00275 CSIBCXfoMatd& SetCol( const int in_nCol, double in_dA0, double in_dA1, double in_dA2, double in_dA3 );
00276
00281 CSIBCXfoMatd& SetIdentity( void );
00282
00283
00284
00285
00286
00297 friend bool AreAlmostEqual( const CSIBCXfoMatd& in_mat1,
00298 const CSIBCXfoMatd& in_mat2,
00299 const double in_dEpsilon = HEXA_EPS );
00300
00308 bool operator ==( const CSIBCMatrix44d& in_mat ) const;
00309
00317 bool operator !=( const CSIBCMatrix44d& in_mat ) const;
00318
00319
00320
00321
00322
00331 CSIBCXfoMatd& Mul( const CSIBCXfoMatd& in_mat1, const CSIBCXfoMatd& in_mat2 );
00332
00340 CSIBCXfoMatd& Mul( const CSIBCXfoMatd& in_mat );
00341
00350 CSIBCXfoMatd& Mul( const CSIBCXfoMatd& in_xfomat, const CSIBCRotMatd& in_rotmat );
00351
00360 CSIBCXfoMatd& Mul( const CSIBCRotMatd& in_rotmat, const CSIBCXfoMatd& in_xfomat );
00361
00362
00373 CSIBCXfoMatd& MulTransByReg( const CSIBCRotMatd& in_rotmat,
00374 const CSIBCXfoMatd& in_xfomat );
00375
00381 double GetDet( void ) const;
00382
00388 double GetDet33( void ) const;
00389
00395 double GetTrace( void ) const;
00396
00402 CSIBCXfoMatd& Transpose( const CSIBCXfoMatd& in_mat );
00403
00408 CSIBCXfoMatd& Transpose( void );
00409
00416 bool Invert( const CSIBCXfoMatd& in_mat );
00417
00423 bool Invert( void );
00424
00431 CSIBCVector3Dd& GetTranslation( CSIBCVector3Dd& out_vctTrs ) const;
00432
00439 CSIBCXfoMatd& SetTranslation( const CSIBCVector3Dd& in_vctTrs );
00440
00447 CSIBCXfoMatd& AddTranslation( const CSIBCVector3Dd& in_vctTrs );
00448
00456 CSIBCRotMatd& GetRotation( CSIBCRotMatd& out_matRot ) const;
00457
00465 CSIBCRotationd& GetRotation( CSIBCRotationd& out_rot ) const;
00466
00473 CSIBCXfoMatd& SetRotation( const CSIBCRotMatd& in_matRot );
00474
00481 CSIBCXfoMatd& AddRotation( const CSIBCRotMatd& in_matRot );
00482
00489 CSIBCVector3Dd& GetScaling( CSIBCVector3Dd& out_vctScl ) const;
00490
00497 CSIBCXfoMatd& SetScaling( const CSIBCVector3Dd& in_vctScl );
00498
00508 CSIBCXfoMatd& AddScaling( const CSIBCVector3Dd& in_vctScl, bool in_bPreScaling = true );
00509
00518 void SetScalingAndRotation( const CSIBCVector3Dd& in_vctScl, CSIBCRotationd& in_rot );
00519
00528 void GetScalingAndRotation( CSIBCVector3Dd& out_vctScl, CSIBCRotationd& out_rot ) const;
00529
00536 void GetAffineDecomposition ( CSIBCRotMatd& out_sclRot, CSIBCXfoMatd& out_matSRT ) const;
00537
00545 void GetSmartDecomposition ( CSIBCVector3D& out_Scale, CSIBCVector3D& out_Rotate, CSIBCVector3D& out_Trans ) const;
00546
00547
00548 protected:
00549
00550
00551
00552 enum {
00553 _3D_X_NEGATIVE = (unsigned char)( 1 << (_3D_NB_BITS_RESERVED_BY_MAT44 + 0) ),
00554 _3D_Y_NEGATIVE = (unsigned char)( 1 << (_3D_NB_BITS_RESERVED_BY_MAT44 + 1) ),
00555 _3D_Z_NEGATIVE = (unsigned char)( 1 << (_3D_NB_BITS_RESERVED_BY_MAT44 + 2) ),
00556 _3D_ALLAXES_NEGATIVE_MASK = (unsigned char)( _3D_X_NEGATIVE | _3D_Y_NEGATIVE | _3D_Z_NEGATIVE ),
00557 };
00558
00559
00560 private:
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572 CSIBCXfoMatd( const CSIBCMatrix44d & );
00573 CSIBCXfoMatd( const CSIBCMatrix33d& in_mat );
00574
00575
00576 CSIBCXfoMatd( const CSIBCXfoMatd& in_mat );
00577 CSIBCXfoMatd& operator =( const CSIBCXfoMatd& in_mat );
00578
00579
00580 void SetSclSignBits( const CSIBCVector3Dd &in_vctScl );
00581 void XORSclSignBits( const CSIBCVector3Dd &in_vctScl );
00582
00583 void SetSclSignBits( const unsigned char in_SclBits );
00584 void XORSclSignBits( const unsigned char in_Bits1, const unsigned char in_Bits2 );
00585 unsigned char GetSclSignBits( ) const;
00586 void ClearSclSignBits();
00587 bool IsSclAxisNegative( int in_axe ) const;
00588 };
00589 typedef CSIBCXfoMatd* LP3DXFOMAT;
00590 typedef const CSIBCXfoMatd* LPC3DXFOMAT;
00591
00592 #endif