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
00040
00041
00042 #define _3D_NB_BITS_RESERVED_BY_XFOMAT (unsigned char)( 3 )
00043
00044
00045
00046
00047
00049
00065 class XSICOREEXPORT CSIBCXfoMatd : private CSIBCMatrix44d
00066 {
00067
00068 public:
00069
00070
00071
00072
00077 CSIBCXfoMatd( void );
00078
00090 CSIBCXfoMatd(
00091 const CSIBCVector4Dd& in_vct0,
00092 const CSIBCVector4Dd& in_vct1,
00093 const CSIBCVector4Dd& in_vct2,
00094 const CSIBCVector4Dd& in_vct3,
00095 const bool in_bAreRows = true );
00096
00116 CSIBCXfoMatd(
00117 const double in_dA00, const double in_dA01, const double in_dA02, const double in_dA03,
00118 const double in_dA10, const double in_dA11, const double in_dA12, const double in_dA13,
00119 const double in_dA20, const double in_dA21, const double in_dA22, const double in_dA23,
00120 const double in_dA30, const double in_dA31, const double in_dA32, const double in_dA33 );
00121
00122
00123
00124
00125
00132 double Get( const int in_nRow, const int in_nCol ) const;
00133
00140 const double * GetArray() const;
00141
00142
00143
00144
00145
00156 CSIBCXfoMatd& Set( int in_nRow, int in_nCol, const double in_dVal );
00157
00167 CSIBCXfoMatd& Set( double in_dVal[4][4] );
00168
00174 CSIBCXfoMatd& Set( double in_dVal[3][3] );
00175
00184 CSIBCXfoMatd& Set( const CSIBCMatrix44d& in_mat );
00185
00195 CSIBCXfoMatd& Set( const CSIBCMatrix33d& in_mat );
00196
00205 CSIBCXfoMatd& Set( const CSIBCXfoMatd& in_mat );
00206
00215 CSIBCXfoMatd& Set( const CSIBCRotMatd& in_mat );
00216
00226 CSIBCXfoMatd& SetWithTranspose( const CSIBCRotMatd& in_mat );
00227
00237 CSIBCXfoMatd& SetRow( const int in_nRow, const CSIBCVector4Dd& in_vct );
00238
00250 CSIBCXfoMatd& SetRow( const int in_nRow, double in_dA0, double in_dA1, double in_dA2, double in_dA3 );
00251
00261 CSIBCXfoMatd& SetCol( const int in_nCol, const CSIBCVector4Dd& in_vct );
00262
00274 CSIBCXfoMatd& SetCol( const int in_nCol, double in_dA0, double in_dA1, double in_dA2, double in_dA3 );
00275
00280 CSIBCXfoMatd& SetIdentity( void );
00281
00282
00283
00284
00285
00296 friend bool AreAlmostEqual( const CSIBCXfoMatd& in_mat1,
00297 const CSIBCXfoMatd& in_mat2,
00298 const double in_dEpsilon = HEXA_EPS );
00299
00307 bool operator ==( const CSIBCMatrix44d& in_mat ) const;
00308
00316 bool operator !=( const CSIBCMatrix44d& in_mat ) const;
00317
00318
00319
00320
00321
00330 CSIBCXfoMatd& Mul( const CSIBCXfoMatd& in_mat1, const CSIBCXfoMatd& in_mat2 );
00331
00339 CSIBCXfoMatd& Mul( const CSIBCXfoMatd& in_mat );
00340
00349 CSIBCXfoMatd& Mul( const CSIBCXfoMatd& in_xfomat, const CSIBCRotMatd& in_rotmat );
00350
00359 CSIBCXfoMatd& Mul( const CSIBCRotMatd& in_rotmat, const CSIBCXfoMatd& in_xfomat );
00360
00361
00372 CSIBCXfoMatd& MulTransByReg( const CSIBCRotMatd& in_rotmat,
00373 const CSIBCXfoMatd& in_xfomat );
00374
00380 double GetDet( void ) const;
00381
00387 double GetDet33( void ) const;
00388
00394 double GetTrace( void ) const;
00395
00401 CSIBCXfoMatd& Transpose( const CSIBCXfoMatd& in_mat );
00402
00407 CSIBCXfoMatd& Transpose( void );
00408
00415 bool Invert( const CSIBCXfoMatd& in_mat );
00416
00422 bool Invert( void );
00423
00430 CSIBCVector3Dd& GetTranslation( CSIBCVector3Dd& out_vctTrs ) const;
00431
00438 CSIBCXfoMatd& SetTranslation( const CSIBCVector3Dd& in_vctTrs );
00439
00446 CSIBCXfoMatd& AddTranslation( const CSIBCVector3Dd& in_vctTrs );
00447
00455 CSIBCRotMatd& GetRotation( CSIBCRotMatd& out_matRot ) const;
00456
00464 CSIBCRotationd& GetRotation( CSIBCRotationd& out_rot ) const;
00465
00472 CSIBCXfoMatd& SetRotation( const CSIBCRotMatd& in_matRot );
00473
00480 CSIBCXfoMatd& AddRotation( const CSIBCRotMatd& in_matRot );
00481
00488 CSIBCVector3Dd& GetScaling( CSIBCVector3Dd& out_vctScl ) const;
00489
00496 CSIBCXfoMatd& SetScaling( const CSIBCVector3Dd& in_vctScl );
00497
00507 CSIBCXfoMatd& AddScaling( const CSIBCVector3Dd& in_vctScl, bool in_bPreScaling = true );
00508
00517 void SetScalingAndRotation( const CSIBCVector3Dd& in_vctScl, CSIBCRotationd& in_rot );
00518
00527 void GetScalingAndRotation( CSIBCVector3Dd& out_vctScl, CSIBCRotationd& out_rot ) const;
00528
00535 void GetAffineDecomposition ( CSIBCRotMatd& out_sclRot, CSIBCXfoMatd& out_matSRT ) const;
00536
00537
00538 protected:
00539
00540
00541
00542 enum {
00543 _3D_X_NEGATIVE = (unsigned char)( 1 << (_3D_NB_BITS_RESERVED_BY_MAT44 + 0) ),
00544 _3D_Y_NEGATIVE = (unsigned char)( 1 << (_3D_NB_BITS_RESERVED_BY_MAT44 + 1) ),
00545 _3D_Z_NEGATIVE = (unsigned char)( 1 << (_3D_NB_BITS_RESERVED_BY_MAT44 + 2) ),
00546 _3D_ALLAXES_NEGATIVE_MASK = (unsigned char)( _3D_X_NEGATIVE | _3D_Y_NEGATIVE | _3D_Z_NEGATIVE ),
00547 };
00548
00549
00550 private:
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562 CSIBCXfoMatd( const CSIBCMatrix44d & );
00563 CSIBCXfoMatd( const CSIBCMatrix33d& in_mat );
00564
00565
00566 CSIBCXfoMatd( const CSIBCXfoMatd& in_mat );
00567 CSIBCXfoMatd& operator =( const CSIBCXfoMatd& in_mat );
00568
00569
00570 void SetSclSignBits( const CSIBCVector3Dd &in_vctScl );
00571 void XORSclSignBits( const CSIBCVector3Dd &in_vctScl );
00572
00573 void SetSclSignBits( const unsigned char in_SclBits );
00574 void XORSclSignBits( const unsigned char in_Bits1, const unsigned char in_Bits2 );
00575 unsigned char GetSclSignBits( ) const;
00576 void ClearSclSignBits();
00577 bool IsSclAxisNegative( int in_axe ) const;
00578 };
00579 typedef CSIBCXfoMatd* LP3DXFOMAT;
00580 typedef const CSIBCXfoMatd* LPC3DXFOMAT;
00581
00582 #endif