00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #if (_MSC_VER > 1000) || defined(SGI_COMPILER)
00013 #pragma once
00014 #endif
00015
00016
00017
00018
00019
00020 #ifndef _XFOMAT_H_
00021 #define _XFOMAT_H_
00022
00023
00024
00025
00026 #include "SIBCMathLib.h"
00027 #include "SIBCMatrix.h"
00028
00029
00030
00031 #define _3D_NB_BITS_RESERVED_BY_XFOMAT (unsigned char)( 3 )
00032
00033
00034
00035
00036
00038
00054 class XSICOREEXPORT CSIBCXfoMatd : private CSIBCMatrix44d
00055 {
00056
00057 public:
00058
00059
00060
00061
00066 CSIBCXfoMatd( void );
00067
00079 CSIBCXfoMatd(
00080 const CSIBCVector4Dd& in_vct0,
00081 const CSIBCVector4Dd& in_vct1,
00082 const CSIBCVector4Dd& in_vct2,
00083 const CSIBCVector4Dd& in_vct3,
00084 const bool in_bAreRows = true );
00085
00105 CSIBCXfoMatd(
00106 const double in_dA00, const double in_dA01, const double in_dA02, const double in_dA03,
00107 const double in_dA10, const double in_dA11, const double in_dA12, const double in_dA13,
00108 const double in_dA20, const double in_dA21, const double in_dA22, const double in_dA23,
00109 const double in_dA30, const double in_dA31, const double in_dA32, const double in_dA33 );
00110
00111
00112
00113
00114
00121 double Get( const int in_nRow, const int in_nCol ) const;
00122
00129 const double * GetArray() const;
00130
00131
00132
00133
00134
00145 CSIBCXfoMatd& Set( int in_nRow, int in_nCol, const double in_dVal );
00146
00156 CSIBCXfoMatd& Set( double in_dVal[4][4] );
00157
00163 CSIBCXfoMatd& Set( double in_dVal[3][3] );
00164
00173 CSIBCXfoMatd& Set( const CSIBCMatrix44d& in_mat );
00174
00184 CSIBCXfoMatd& Set( const CSIBCMatrix33d& in_mat );
00185
00194 CSIBCXfoMatd& Set( const CSIBCXfoMatd& in_mat );
00195
00204 CSIBCXfoMatd& Set( const CSIBCRotMatd& in_mat );
00205
00215 CSIBCXfoMatd& SetWithTranspose( const CSIBCRotMatd& in_mat );
00216
00226 CSIBCXfoMatd& SetRow( const int in_nRow, const CSIBCVector4Dd& in_vct );
00227
00239 CSIBCXfoMatd& SetRow( const int in_nRow, double in_dA0, double in_dA1, double in_dA2, double in_dA3 );
00240
00250 CSIBCXfoMatd& SetCol( const int in_nCol, const CSIBCVector4Dd& in_vct );
00251
00263 CSIBCXfoMatd& SetCol( const int in_nCol, double in_dA0, double in_dA1, double in_dA2, double in_dA3 );
00264
00269 CSIBCXfoMatd& SetIdentity( void );
00270
00271
00272
00273
00274
00285 friend bool AreAlmostEqual( const CSIBCXfoMatd& in_mat1,
00286 const CSIBCXfoMatd& in_mat2,
00287 const double in_dEpsilon = HEXA_EPS );
00288
00296 bool operator ==( const CSIBCMatrix44d& in_mat ) const;
00297
00305 bool operator !=( const CSIBCMatrix44d& in_mat ) const;
00306
00307
00308
00309
00310
00319 CSIBCXfoMatd& Mul( const CSIBCXfoMatd& in_mat1, const CSIBCXfoMatd& in_mat2 );
00320
00328 CSIBCXfoMatd& Mul( const CSIBCXfoMatd& in_mat );
00329
00338 CSIBCXfoMatd& Mul( const CSIBCXfoMatd& in_xfomat, const CSIBCRotMatd& in_rotmat );
00339
00348 CSIBCXfoMatd& Mul( const CSIBCRotMatd& in_rotmat, const CSIBCXfoMatd& in_xfomat );
00349
00350
00361 CSIBCXfoMatd& MulTransByReg( const CSIBCRotMatd& in_rotmat,
00362 const CSIBCXfoMatd& in_xfomat );
00363
00369 double GetDet( void ) const;
00370
00376 double GetDet33( void ) const;
00377
00383 double GetTrace( void ) const;
00384
00390 CSIBCXfoMatd& Transpose( const CSIBCXfoMatd& in_mat );
00391
00396 CSIBCXfoMatd& Transpose( void );
00397
00404 bool Invert( const CSIBCXfoMatd& in_mat );
00405
00411 bool Invert( void );
00412
00419 CSIBCVector3Dd& GetTranslation( CSIBCVector3Dd& out_vctTrs ) const;
00420
00427 CSIBCXfoMatd& SetTranslation( const CSIBCVector3Dd& in_vctTrs );
00428
00435 CSIBCXfoMatd& AddTranslation( const CSIBCVector3Dd& in_vctTrs );
00436
00444 CSIBCRotMatd& GetRotation( CSIBCRotMatd& out_matRot ) const;
00445
00453 CSIBCRotationd& GetRotation( CSIBCRotationd& out_rot ) const;
00454
00461 CSIBCXfoMatd& SetRotation( const CSIBCRotMatd& in_matRot );
00462
00469 CSIBCXfoMatd& AddRotation( const CSIBCRotMatd& in_matRot );
00470
00477 CSIBCVector3Dd& GetScaling( CSIBCVector3Dd& out_vctScl ) const;
00478
00485 CSIBCXfoMatd& SetScaling( const CSIBCVector3Dd& in_vctScl );
00486
00496 CSIBCXfoMatd& AddScaling( const CSIBCVector3Dd& in_vctScl, bool in_bPreScaling = true );
00497
00506 void SetScalingAndRotation( const CSIBCVector3Dd& in_vctScl, CSIBCRotationd& in_rot );
00507
00516 void GetScalingAndRotation( CSIBCVector3Dd& out_vctScl, CSIBCRotationd& out_rot ) const;
00517
00524 void GetAffineDecomposition ( CSIBCRotMatd& out_sclRot, CSIBCXfoMatd& out_matSRT ) const;
00525
00533 void GetSmartDecomposition ( CSIBCVector3D& out_Scale, CSIBCVector3D& out_Rotate, CSIBCVector3D& out_Trans ) const;
00534
00535
00536 protected:
00537
00538
00539
00540 enum {
00541 _3D_X_NEGATIVE = (unsigned char)( 1 << (_3D_NB_BITS_RESERVED_BY_MAT44 + 0) ),
00542 _3D_Y_NEGATIVE = (unsigned char)( 1 << (_3D_NB_BITS_RESERVED_BY_MAT44 + 1) ),
00543 _3D_Z_NEGATIVE = (unsigned char)( 1 << (_3D_NB_BITS_RESERVED_BY_MAT44 + 2) ),
00544 _3D_ALLAXES_NEGATIVE_MASK = (unsigned char)( _3D_X_NEGATIVE | _3D_Y_NEGATIVE | _3D_Z_NEGATIVE ),
00545 };
00546
00547
00548 private:
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560 CSIBCXfoMatd( const CSIBCMatrix44d & );
00561 CSIBCXfoMatd( const CSIBCMatrix33d& in_mat );
00562
00563
00564 CSIBCXfoMatd( const CSIBCXfoMatd& in_mat );
00565 CSIBCXfoMatd& operator =( const CSIBCXfoMatd& in_mat );
00566
00567
00568 void SetSclSignBits( const CSIBCVector3Dd &in_vctScl );
00569 void XORSclSignBits( const CSIBCVector3Dd &in_vctScl );
00570
00571 void SetSclSignBits( const unsigned char in_SclBits );
00572 void XORSclSignBits( const unsigned char in_Bits1, const unsigned char in_Bits2 );
00573 unsigned char GetSclSignBits( ) const;
00574 void ClearSclSignBits();
00575 bool IsSclAxisNegative( int in_axe ) const;
00576 };
00577 typedef CSIBCXfoMatd* LP3DXFOMAT;
00578 typedef const CSIBCXfoMatd* LPC3DXFOMAT;
00579
00580 #endif