SIBCXfoMatd.h



Your Ad Here

00001 //***************************************************************************************
00002 //
00003 // File supervisor: Softimage 3D Games & 3D Bridge team
00004 //
00005 // (c) Copyright 1999-2002 Avid Technology, Inc. . All rights reserved.
00006 //
00007 //***************************************************************************************
00008 
00009 /****************************************************************************************
00010 THIS CODE IS PUBLISHED AS A SAMPLE ONLY AND IS PROVIDED "AS IS".
00011 IN NO EVENT SHALL SOFTIMAGE, AVID TECHNOLOGY, INC. AND/OR THEIR RESPECTIVE
00012 SUPPLIERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
00013 DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00014 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
00015 CONNECTION WITH THE USE OR PERFORMANCE OF THIS CODE .
00016 
00017 COPYRIGHT NOTICE. Copyright © 1999-2002 Avid Technology Inc. . All rights reserved. 
00018 
00019 SOFTIMAGE is a registered trademark of Avid Technology Inc. or its subsidiaries 
00020 or divisions. Windows NT is a registered trademark of Microsoft Corp. All other
00021 trademarks contained herein are the property of their respective owners. 
00022 ****************************************************************************************/
00023 
00024 #if (_MSC_VER > 1000) || defined(SGI_COMPILER)
00025 #pragma once
00026 #endif
00027 
00028 //******************************************************************************
00029 // Defines
00030 //******************************************************************************
00031 
00032 #ifndef _XFOMAT_H_
00033 #define _XFOMAT_H_
00034 
00035 //******************************************************************************
00036 // Includes
00037 //******************************************************************************
00038 #include "SIBCMathLib.h"
00039 
00040 //This number must represent the number of bits flags in 
00041 //CSIBCMatrix44d::m_MaskInfo reserved for the specific usage of CSIBCXfoMatd.
00042 #define _3D_NB_BITS_RESERVED_BY_XFOMAT (unsigned char)( 3 ) 
00043 
00044 //******************************************************************************
00045 // CSIBCXfoMatd | 4x4 transformation matrix.
00046 //******************************************************************************
00047 
00049 
00065 class XSICOREEXPORT CSIBCXfoMatd : private CSIBCMatrix44d
00066 {
00067     // Public members
00068     public:
00069         //****************************************
00070         // Constructors/destructor:
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         // General access functions:
00124         //****************************************
00125 
00132         double Get( const int in_nRow, const int in_nCol ) const;
00133 
00140         const double * GetArray() const;
00141 
00142         //****************************************
00143         // Matrix element modification functions:
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         // Matrix comparison functions:
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         // Matrix algebra functions:
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     // Protected members
00538     protected:
00539 
00540         // If you have to reserve other bits in CSIBCMatrix44d::m_MaskInfo for the specific usage of CSIBCMatrix44d
00541         // please update the value of _3D_NB_BITS_RESERVED_BY_XFOMAT accordingly.
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     // Private members
00550     private:
00551 
00552         // Please do not re-enable the following cast operator as it will cause problems for the following Scenario:
00553         // CSIBCMatrix44d l_mat;
00554         // CSIBCVector3Dd l_vct;
00555         // l_vct.Mul( l_vct, l_mat );
00556         // there are two Mul functions applicable:
00557         // 1-   CSIBCVector3Dd & CSIBCVector3Dd::Mul( const CSIBCVector3Dd &, const CSIBCMatrix44d & );
00558         // 2-   CSIBCVector3Dd & CSIBCVector3Dd::Mul( const CSIBCVector3Dd &, const CSIBCXfoMatd & );
00559         // Unfortunately, if the following operator is enabled, the second Mul function will be taken
00560         // which is not what the client wants !!!
00561         // EC.
00562         CSIBCXfoMatd( const CSIBCMatrix44d & ); // Disable this cast operator
00563         CSIBCXfoMatd( const CSIBCMatrix33d& in_mat );
00564 
00565         //Disable copy constructor and operator =
00566         CSIBCXfoMatd( const CSIBCXfoMatd& in_mat );
00567         CSIBCXfoMatd& operator =( const CSIBCXfoMatd& in_mat );
00568 
00569         //Methods to handles SignBits for the scaling factor.
00570         void SetSclSignBits( const CSIBCVector3Dd &in_vctScl ); // SetSclSignBits | Set m_MaskInfo from in_vctScl.
00571         void XORSclSignBits( const CSIBCVector3Dd &in_vctScl ); // XORSclSignBits | XOR m_MaskInfo from in_vctScl.
00572 
00573         void SetSclSignBits( const unsigned char in_SclBits );  // SetSclSignBits | Set the sign bits of m_MaskInfo to those of in_SclBits.
00574         void XORSclSignBits( const unsigned char in_Bits1, const unsigned char in_Bits2 );// XORSclSignBits | Return the XOR of in_Mask1 and in_Mask2 masked with _3D_ALLAXES_NEGATIVE_MASK.
00575         unsigned char GetSclSignBits( ) const;              // GetSclSignBits | Return the sign bits sub-part of m_MaskInfo.
00576         void ClearSclSignBits();                            // ClearSclSignBits | Clear the bit signs part of m_MaskInfo
00577         bool IsSclAxisNegative( int in_axe ) const;         // IsSclAxisNegative | Look if one scl bit is set.
00578 };
00579 typedef CSIBCXfoMatd* LP3DXFOMAT;
00580 typedef const CSIBCXfoMatd* LPC3DXFOMAT;
00581 
00582 #endif

Return to Softimage XSI Index


Your Ad Here