# SIBCMatrix44d.h

    00001 //***************************************************************************************
    00002 //
    00003 // File supervisor: Crosswalk team
    00004 //
    00005 // Copyright 2008 Autodesk, Inc.  All rights reserved.
    00006 // Use of this software is subject to the terms of the Autodesk license agreement
    00007 // provided at the time of installation or download, or which otherwise accompanies
    00008 // this software in either electronic or hard copy form.
    00009 //
    00010 //***************************************************************************************
    00011
    00012 #if (_MSC_VER > 1000) || defined(SGI_COMPILER)
    00013 #pragma once
    00014 #endif
    00015
    00016 //******************************************************************************
    00017 // Defines
    00018 //******************************************************************************
    00019 #ifndef _MATRIX44_H_
    00020 #define _MATRIX44_H_
    00021
    00022 //******************************************************************************
    00023 // Includes
    00024 //******************************************************************************
    00025 #include <assert.h>
    00026 #include "SIBCMathLib.h"
    00027
    00028 #define _3D_NB_BITS_RESERVED_BY_MAT44 (unsigned char)1  //This number must represent the number of bits flags in m_MaskInfo
    00029                                                         //reserved for the specific usage of CSIBCMatrix44d
    00030
    00031 //******************************************************************************
    00032 //
    00033 // CSIBCMatrix44d | General 4X4 matrix.
    00034 //
    00035 //******************************************************************************
    00036
    00038
    00047 class XSICOREEXPORT CSIBCMatrix44d
    00048 {
    00049     public:
    00050
    00051         //****************************************
    00052         // Constructors/destructor:
    00053         //****************************************
    00054
    00059         CSIBCMatrix44d( void );
    00060
    00072         CSIBCMatrix44d(
    00073             const CSIBCVector4Dd& in_vct0,
    00074             const CSIBCVector4Dd& in_vct1,
    00075             const CSIBCVector4Dd& in_vct2,
    00076             const CSIBCVector4Dd& in_vct3,
    00077             const bool in_bAreRows = true );
    00078
    00098         CSIBCMatrix44d(
    00099             const double in_dA00, const double in_dA01, const double in_dA02, const double in_dA03,
    00100             const double in_dA10, const double in_dA11, const double in_dA12, const double in_dA13,
    00101             const double in_dA20, const double in_dA21, const double in_dA22, const double in_dA23,
    00102             const double in_dA30, const double in_dA31, const double in_dA32, const double in_dA33 );
    00103
    00104         // Destructor.
    00105         ~CSIBCMatrix44d();
    00106
    00107         //****************************************
    00108         // General access functions:
    00109         //****************************************
    00110
    00117         double Get( const int in_nRow, const int in_nCol ) const;
    00118
    00119         //****************************************
    00120         // Matrix element modification functions:
    00121         //****************************************
    00122
    00133         CSIBCMatrix44d& Set( int in_nRow, int in_nCol, const double in_dVal );
    00134
    00158         CSIBCMatrix44d& Set(
    00159             const double in_dA00, const double in_dA01, const double in_dA02, const double in_dA03,
    00160             const double in_dA10, const double in_dA11, const double in_dA12, const double in_dA13,
    00161             const double in_dA20, const double in_dA21, const double in_dA22, const double in_dA23,
    00162             const double in_dA30, const double in_dA31, const double in_dA32, const double in_dA33 );
    00163
    00164
    00174         CSIBCMatrix44d& Set( const double in_dArray[4][4] );
    00175
    00185         CSIBCMatrix44d& Set( const double *in_dPtr )
    00186         {
    00187             return Set( (const double (*)[4] ) in_dPtr );
    00188         };
    00189
    00190
    00199         CSIBCMatrix44d& Set( const CSIBCMatrix44d& in_mat );
    00200
    00210         CSIBCMatrix44d& SetRow( const int in_nRow, const CSIBCVector4Dd& in_vct );
    00211
    00223         CSIBCMatrix44d& SetRow( const int in_nRow, double in_dA0, double in_dA1,
    00224             double in_dA2, double in_dA3 );
    00225
    00235         CSIBCMatrix44d& SetCol( const int in_nCol, const CSIBCVector4Dd& in_vct );
    00236
    00248         CSIBCMatrix44d& SetCol( const int in_nCol, double in_dA0, double in_dA1,
    00249             double in_dA2, double in_dA3 );
    00250
    00256         CSIBCMatrix44d& SetNull();
    00257
    00263         CSIBCMatrix44d& SetIdentity();
    00264
    00265         //****************************************
    00266         // Matrix comparison functions:
    00267         //****************************************
    00268
    00279         friend bool AreAlmostEqual( const CSIBCMatrix44d& in_mat1,
    00280             const CSIBCMatrix44d& in_mat2, const double in_dEpsilon = PICO_EPS );
    00281
    00289         bool operator ==( const CSIBCMatrix44d& in_mat ) const;
    00290
    00298         bool operator !=( const CSIBCMatrix44d& in_mat ) const;
    00299
    00309         bool IsNull( const double in_dEpsilon=PICO_EPS ) const;
    00310
    00311         //****************************************
    00312         // Matrix algebra functions:
    00313         //****************************************
    00314
    00322         CSIBCMatrix44d& Add( const CSIBCMatrix44d& in_mat1, const CSIBCMatrix44d& in_mat2 );
    00323
    00330         CSIBCMatrix44d& Add( const CSIBCMatrix44d& in_mat );
    00331
    00339         CSIBCMatrix44d& Sub( const CSIBCMatrix44d& in_mat1, const CSIBCMatrix44d& in_mat2 );
    00340
    00348         CSIBCMatrix44d& Sub( const CSIBCMatrix44d& in_mat );
    00349
    00360         CSIBCMatrix44d& Mul( const CSIBCMatrix44d& in_mat1, const CSIBCMatrix44d& in_mat2 );
    00361
    00371         CSIBCMatrix44d& Mul( const CSIBCMatrix44d& in_mat );
    00372
    00383         CSIBCMatrix44d& MulTransByReg( const CSIBCMatrix44d& in_mat1, const CSIBCMatrix44d& in_mat2 );
    00384
    00395         CSIBCMatrix44d& MulRegByTrans( const CSIBCMatrix44d& in_mat1, const CSIBCMatrix44d& in_mat2 );
    00396
    00403         CSIBCMatrix44d& Negate( const CSIBCMatrix44d& in_mat );
    00404
    00410         CSIBCMatrix44d& Negate();
    00411
    00420         CSIBCMatrix44d& Mul( const double in_dFactor, const CSIBCMatrix44d& in_mat );
    00421
    00430         CSIBCMatrix44d& Mul( const CSIBCMatrix44d& in_mat, const double in_dFactor );
    00431
    00438         CSIBCMatrix44d& Mul( const double in_dFactor );
    00439
    00448         CSIBCMatrix44d& Div( const CSIBCMatrix44d& in_mat, const double in_dFactor );
    00449
    00456         CSIBCMatrix44d& Div( const double in_dFactor );
    00457
    00463         double GetDet( void ) const;
    00464
    00473         double GetDet( int in_nRow, int in_nCol ) const;
    00474
    00479         double GetTrace( void ) const;
    00480
    00487         CSIBCMatrix44d& Transpose( const CSIBCMatrix44d& in_mat );
    00488
    00494         CSIBCMatrix44d& Transpose( void );
    00495
    00503         bool Invert( const CSIBCMatrix44d& in_mat );
    00504
    00511         bool Invert( void );
    00512
    00521         bool TransposeInverse( const CSIBCMatrix44d& in_mat );
    00522
    00530         bool TransposeInverse( void );
    00531
    00532         //****************************************
    00533         // Utility functions:
    00534         //****************************************
    00535
    00536         //****************************************
    00537         // To be implemented later:
    00538         //****************************************
    00539
    00540         // Set this matrix to the symmetrical of the input matrix.
    00542         CSIBCMatrix44d& Symmetry( CSIBCMatrix44d& in_mat ) const;
    00543
    00544         // Set this matrix to its symmetrical.
    00546         CSIBCMatrix44d& Symmetry( void ) const;
    00547
    00548         // Set this matrix to the adjoint of the input matrix.
    00550         CSIBCMatrix44d& Adjoint( CSIBCMatrix44d& in_mat ) const;
    00551
    00552         // Set this matrix to its adjoint.
    00554         CSIBCMatrix44d& Adjoint( void ) const;
    00555
    00556         // Set this matrix to the product of V1^T and V2.
    00558         void SetOuterProduct( const CSIBCVector4Dd& in_vct1, const CSIBCVector4Dd& in_vct2 );
    00559
    00560     // Protected members
    00561     protected:
    00562
    00563         //****************************************
    00564         // Protected data
    00565         //****************************************
    00566         // double[4][4] | CSIBCMatrix44d | m_dMat | Matrix itself.
    00567         double m_dMat[4][4];
    00568
    00569         //****************************************
    00570         // Utility functions:
    00571         //****************************************
    00572         // Computes the inverse of a matrix.
    00573         bool ComputeInverse( const double in_dMat[4][4],
    00574             double out_dInv[4][4], const bool bTransposeResult=false );
    00575
    00576
    00577    protected:
    00578         //****************************************
    00579         // Private data
    00580         //****************************************
    00581         // unsigned char | CSIBCMatrix44d | m_MaskInfo |
    00582         // Flag to indicate if matrix content has changed
    00583         // since last call to SetContentUnchanged().
    00584
    00585         unsigned char   m_MaskInfo;
    00586 };
    00587
    00588
    00589 #endif