xsi_matrix4f.h
Go to the documentation of this file.
00001 //*****************************************************************************
00011 //*****************************************************************************
00012 
00013 #if (_MSC_VER > 1000) || defined(SGI_COMPILER)
00014 #pragma once
00015 #endif
00016 
00017 #ifndef __XSIMATRIX4F_H__
00018 #define __XSIMATRIX4F_H__
00019 
00020 #include "sicppsdk.h"
00021 #include "xsi_math.h"
00022 
00023 namespace XSI {
00024 namespace MATH {
00025 
00026 //*****************************************************************************
00031 //*****************************************************************************
00032 class SICPPSDKDECL CMatrix4f
00033 {
00034 public:
00035 
00037     SICPPSDK_INLINE CMatrix4f();
00038 
00057     SICPPSDK_INLINE CMatrix4f(float in_f00, float in_f01, float in_f02, float in_f03,
00058              float in_f10, float in_f11, float in_f12, float in_f13,
00059              float in_f20, float in_f21, float in_f22, float in_f23,
00060              float in_f30, float in_f31, float in_f32, float in_f33);
00061 
00065     SICPPSDK_INLINE CMatrix4f( const CMatrix4f& in_matrix4 );
00066 
00068     SICPPSDK_INLINE ~CMatrix4f();
00069 
00074     SICPPSDK_INLINE CMatrix4f & operator=( const CMatrix4f & in_matrix4 );
00075 
00081     SICPPSDK_INLINE CMatrix4f & operator*=(const CMatrix4f & in_matrix4);
00082 
00086     SICPPSDK_INLINE CMatrix4f&  SetIdentity();
00087 
00091     SICPPSDK_INLINE bool InvertInPlace();
00092 
00097     SICPPSDK_INLINE bool Invert(const CMatrix4f& in_matrix4);
00098 
00103     SICPPSDK_INLINE bool TransposeInverseInPlace();
00104 
00110     SICPPSDK_INLINE bool TransposeInverse(const CMatrix4f& in_matrix4);
00111 
00114     SICPPSDK_INLINE void TransposeInPlace();
00115 
00119     SICPPSDK_INLINE void Transpose(const CMatrix4f& in_matrix4);
00120 
00126     SICPPSDK_INLINE CMatrix4f& MulInPlace(const CMatrix4f& in_matrix4);
00127 
00134     SICPPSDK_INLINE CMatrix4f& Mul(const CMatrix4f& in_matrix4A, const CMatrix4f& in_matrix4B);
00135 
00154     SICPPSDK_INLINE void Get
00155     (
00156         float& io_f00, float& io_f01, float& io_f02, float& io_f03,
00157         float& io_f10, float& io_f11, float& io_f12, float& io_f13,
00158         float& io_f20, float& io_f21, float& io_f22, float& io_f23,
00159         float& io_f30, float& io_f31, float& io_f32, float& io_f33
00160     ) const;
00161 
00180     SICPPSDK_INLINE void Set(   float in_f00, float in_f01, float in_f02, float in_f03,
00181                                 float in_f10, float in_f11, float in_f12, float in_f13,
00182                                 float in_f20, float in_f21, float in_f22, float in_f23,
00183                                 float in_f30, float in_f31, float in_f32, float in_f33);
00184 
00188     SICPPSDK_INLINE float* Get();
00189 
00193     SICPPSDK_INLINE void Set(const float in_vals[4][4]);
00194 
00200     SICPPSDK_INLINE float GetValue(short in_sRow,short in_sCol )const;
00201 
00207     SICPPSDK_INLINE void SetValue(short in_sRow, short in_sCol, float in_fVal );
00208 
00214     SICPPSDK_INLINE bool EpsilonEquals
00215     (
00216         const CMatrix4f& in_matrix4,
00217         float in_fEpsilon
00218     ) const;
00219 
00224     SICPPSDK_INLINE bool Equals(const CMatrix4f& in_matrix4) const;
00225 
00231     SICPPSDK_INLINE bool operator ==(const CMatrix4f & in_matrix4 ) const;
00232 
00238     SICPPSDK_INLINE bool operator !=(const CMatrix4f & in_matrix4 ) const;
00239 
00246     SICPPSDK_INLINE bool operator < (const CMatrix4f& in_matrix4 )const;
00247 
00248 private:
00249     float m_fMat[4][4];
00250     unsigned char m_maskInfo;
00251     
00252     SICPPSDK_INLINE bool ComputeInverse
00253     (
00254         const float in_fMat[4][4],
00255         float out_fInv[4][4],
00256         const bool bTransposeResult = false
00257     );
00258 };
00259 
00260 //inline functions
00261 SICPPSDK_INLINE CMatrix4f::CMatrix4f() : m_maskInfo(0)
00262 {
00263     m_fMat[0][0] = 0.0;
00264     m_fMat[0][1] = 0.0;
00265     m_fMat[0][2] = 0.0;
00266     m_fMat[0][3] = 0.0;
00267     m_fMat[1][0] = 0.0;
00268     m_fMat[1][1] = 0.0;
00269     m_fMat[1][2] = 0.0;
00270     m_fMat[1][3] = 0.0;
00271     m_fMat[2][0] = 0.0;
00272     m_fMat[2][1] = 0.0;
00273     m_fMat[2][2] = 0.0;
00274     m_fMat[2][3] = 0.0;
00275     m_fMat[3][0] = 0.0;
00276     m_fMat[3][1] = 0.0;
00277     m_fMat[3][2] = 0.0;
00278     m_fMat[3][3] = 0.0;
00279 }
00280 
00281 SICPPSDK_INLINE CMatrix4f::CMatrix4f
00282 (
00283     float in_f00, float in_f01, float in_f02, float in_f03,
00284     float in_f10, float in_f11, float in_f12, float in_f13,
00285     float in_f20, float in_f21, float in_f22, float in_f23,
00286     float in_f30, float in_f31, float in_f32, float in_f33
00287 ) : m_maskInfo(0)
00288 {
00289     m_fMat[0][0] = in_f00;
00290     m_fMat[0][1] = in_f01;
00291     m_fMat[0][2] = in_f02;
00292     m_fMat[0][3] = in_f03;
00293     m_fMat[1][0] = in_f10;
00294     m_fMat[1][1] = in_f11;
00295     m_fMat[1][2] = in_f12;
00296     m_fMat[1][3] = in_f13;
00297     m_fMat[2][0] = in_f20;
00298     m_fMat[2][1] = in_f21;
00299     m_fMat[2][2] = in_f22;
00300     m_fMat[2][3] = in_f23;
00301     m_fMat[3][0] = in_f30;
00302     m_fMat[3][1] = in_f31;
00303     m_fMat[3][2] = in_f32;
00304     m_fMat[3][3] = in_f33;
00305 }
00306 
00307 SICPPSDK_INLINE CMatrix4f::CMatrix4f(const CMatrix4f& in_matrix4)
00308 {
00309     m_fMat[0][0] = in_matrix4.m_fMat[0][0];
00310     m_fMat[0][1] = in_matrix4.m_fMat[0][1];
00311     m_fMat[0][2] = in_matrix4.m_fMat[0][2];
00312     m_fMat[0][3] = in_matrix4.m_fMat[0][3];
00313     m_fMat[1][0] = in_matrix4.m_fMat[1][0];
00314     m_fMat[1][1] = in_matrix4.m_fMat[1][1];
00315     m_fMat[1][2] = in_matrix4.m_fMat[1][2];
00316     m_fMat[1][3] = in_matrix4.m_fMat[1][3];
00317     m_fMat[2][0] = in_matrix4.m_fMat[2][0];
00318     m_fMat[2][1] = in_matrix4.m_fMat[2][1];
00319     m_fMat[2][2] = in_matrix4.m_fMat[2][2];
00320     m_fMat[2][3] = in_matrix4.m_fMat[2][3];
00321     m_fMat[3][0] = in_matrix4.m_fMat[3][0];
00322     m_fMat[3][1] = in_matrix4.m_fMat[3][1];
00323     m_fMat[3][2] = in_matrix4.m_fMat[3][2];
00324     m_fMat[3][3] = in_matrix4.m_fMat[3][3];
00325     m_maskInfo = in_matrix4.m_maskInfo;
00326 }
00327 
00328 SICPPSDK_INLINE CMatrix4f::~CMatrix4f()
00329 {}
00330 
00331 SICPPSDK_INLINE CMatrix4f& CMatrix4f::operator=( const CMatrix4f & in_matrix4 )
00332 {
00333     m_fMat[0][0] = in_matrix4.m_fMat[0][0];
00334     m_fMat[0][1] = in_matrix4.m_fMat[0][1];
00335     m_fMat[0][2] = in_matrix4.m_fMat[0][2];
00336     m_fMat[0][3] = in_matrix4.m_fMat[0][3];
00337     m_fMat[1][0] = in_matrix4.m_fMat[1][0];
00338     m_fMat[1][1] = in_matrix4.m_fMat[1][1];
00339     m_fMat[1][2] = in_matrix4.m_fMat[1][2];
00340     m_fMat[1][3] = in_matrix4.m_fMat[1][3];
00341     m_fMat[2][0] = in_matrix4.m_fMat[2][0];
00342     m_fMat[2][1] = in_matrix4.m_fMat[2][1];
00343     m_fMat[2][2] = in_matrix4.m_fMat[2][2];
00344     m_fMat[2][3] = in_matrix4.m_fMat[2][3];
00345     m_fMat[3][0] = in_matrix4.m_fMat[3][0];
00346     m_fMat[3][1] = in_matrix4.m_fMat[3][1];
00347     m_fMat[3][2] = in_matrix4.m_fMat[3][2];
00348     m_fMat[3][3] = in_matrix4.m_fMat[3][3];
00349     m_maskInfo = in_matrix4.m_maskInfo;
00350     return *this;
00351 }
00352 
00353 SICPPSDK_INLINE CMatrix4f& CMatrix4f::operator*=(const CMatrix4f& in_matrix4)
00354 {
00355     return MulInPlace(in_matrix4);
00356 }
00357 
00358 SICPPSDK_INLINE CMatrix4f& CMatrix4f::SetIdentity()
00359 {
00360     m_fMat[0][0] = 1.0;
00361     m_fMat[0][1] = 0.0;
00362     m_fMat[0][2] = 0.0;
00363     m_fMat[0][3] = 0.0;
00364     m_fMat[1][0] = 0.0;
00365     m_fMat[1][1] = 1.0;
00366     m_fMat[1][2] = 0.0;
00367     m_fMat[1][3] = 0.0;
00368     m_fMat[2][0] = 0.0;
00369     m_fMat[2][1] = 0.0;
00370     m_fMat[2][2] = 1.0;
00371     m_fMat[2][3] = 0.0;
00372     m_fMat[3][0] = 0.0;
00373     m_fMat[3][1] = 0.0;
00374     m_fMat[3][2] = 0.0;
00375     m_fMat[3][3] = 1.0;
00376     return *this;
00377 }
00378 
00379 SICPPSDK_INLINE bool CMatrix4f::InvertInPlace()
00380 {
00381     return Invert(*this);
00382 }
00383 
00384 SICPPSDK_INLINE bool CMatrix4f::Invert(const CMatrix4f& in_matrix4)
00385 {
00386     float fInv[4][4];
00387 
00388     if (ComputeInverse(in_matrix4.m_fMat, fInv))
00389     {
00390         Set(fInv);
00391         return true;
00392     }
00393     else // singular matrix
00394     {
00395         return false;
00396     }
00397 }
00398 
00399 SICPPSDK_INLINE bool CMatrix4f::TransposeInverseInPlace()
00400 {
00401     return TransposeInverse(*this);
00402 }
00403 
00404 SICPPSDK_INLINE bool CMatrix4f::TransposeInverse(const CMatrix4f& in_matrix4)
00405 {
00406     float fTransInv[4][4];
00407 
00408     if(ComputeInverse(in_matrix4.m_fMat, fTransInv, true))
00409     {
00410         Set(fTransInv);
00411         return true;
00412     }
00413     else // singular matrix
00414     {
00415         return false;
00416     }
00417 }
00418 
00419 SICPPSDK_INLINE void CMatrix4f::TransposeInPlace()
00420 {
00421     Transpose(*this);
00422 }
00423 
00424 SICPPSDK_INLINE void CMatrix4f::Transpose(const CMatrix4f& in_matrix4)
00425 {
00426     float  dTempMat[4][4];
00427     for(int nR=0; nR<4; nR++)
00428         for(int nC=0; nC<4; nC++)
00429             dTempMat[nR][nC] = in_matrix4.m_fMat[nC][nR];
00430     Set(dTempMat);
00431 }
00432 
00433 SICPPSDK_INLINE CMatrix4f&  CMatrix4f::MulInPlace(const CMatrix4f& in_matrix4)
00434 {
00435     return Mul(*this,in_matrix4);
00436 }
00437 
00438 SICPPSDK_INLINE CMatrix4f&  CMatrix4f::Mul
00439 (
00440  const CMatrix4f& in_matrix4A,
00441  const CMatrix4f& in_matrix4B
00442 )
00443 {
00444     float  dTempMat[4][4];
00445 
00446     for(int nR=0; nR<4; nR++)
00447         for(int nC=0; nC<4; nC++)
00448             dTempMat[nR][nC] =
00449                 in_matrix4A.m_fMat[nR][0] * in_matrix4B.m_fMat[0][nC] +
00450                 in_matrix4A.m_fMat[nR][1] * in_matrix4B.m_fMat[1][nC] +
00451                 in_matrix4A.m_fMat[nR][2] * in_matrix4B.m_fMat[2][nC] +
00452                 in_matrix4A.m_fMat[nR][3] * in_matrix4B.m_fMat[3][nC];
00453 
00454     Set(dTempMat);
00455     return (*this);
00456 }
00457 
00458 SICPPSDK_INLINE void CMatrix4f::Get
00459 (
00460     float& io_f00, float& io_f01, float& io_f02, float& io_f03,
00461     float& io_f10, float& io_f11, float& io_f12, float& io_f13,
00462     float& io_f20, float& io_f21, float& io_f22, float& io_f23,
00463     float& io_f30, float& io_f31, float& io_f32, float& io_f33
00464 ) const
00465 {
00466 
00467     io_f00 = m_fMat[0][0];
00468     io_f01 = m_fMat[0][1];
00469     io_f02 = m_fMat[0][2];
00470     io_f03 = m_fMat[0][3];
00471     io_f10 = m_fMat[1][0];
00472     io_f11 = m_fMat[1][1];
00473     io_f12 = m_fMat[1][2];
00474     io_f13 = m_fMat[1][3];
00475     io_f20 = m_fMat[2][0];
00476     io_f21 = m_fMat[2][1];
00477     io_f22 = m_fMat[2][2];
00478     io_f23 = m_fMat[2][3];
00479     io_f30 = m_fMat[3][0];
00480     io_f31 = m_fMat[3][1];
00481     io_f32 = m_fMat[3][2];
00482     io_f33 = m_fMat[3][3];
00483 }
00484 
00485 SICPPSDK_INLINE void CMatrix4f::Set
00486 (
00487     float in_f00, float in_f01, float in_f02, float in_f03,
00488     float in_f10, float in_f11, float in_f12, float in_f13,
00489     float in_f20, float in_f21, float in_f22, float in_f23,
00490     float in_f30, float in_f31, float in_f32, float in_f33
00491 )
00492 {
00493     m_fMat[0][0] = in_f00;
00494     m_fMat[0][1] = in_f01;
00495     m_fMat[0][2] = in_f02;
00496     m_fMat[0][3] = in_f03;
00497     m_fMat[1][0] = in_f10;
00498     m_fMat[1][1] = in_f11;
00499     m_fMat[1][2] = in_f12;
00500     m_fMat[1][3] = in_f13;
00501     m_fMat[2][0] = in_f20;
00502     m_fMat[2][1] = in_f21;
00503     m_fMat[2][2] = in_f22;
00504     m_fMat[2][3] = in_f23;
00505     m_fMat[3][0] = in_f30;
00506     m_fMat[3][1] = in_f31;
00507     m_fMat[3][2] = in_f32;
00508     m_fMat[3][3] = in_f33;
00509 }
00510 
00511 SICPPSDK_INLINE void CMatrix4f::Set(const float in_matrix4[4][4])
00512 {
00513     m_fMat[0][0] = in_matrix4[0][0];
00514     m_fMat[0][1] = in_matrix4[0][1];
00515     m_fMat[0][2] = in_matrix4[0][2];
00516     m_fMat[0][3] = in_matrix4[0][3];
00517     m_fMat[1][0] = in_matrix4[1][0];
00518     m_fMat[1][1] = in_matrix4[1][1];
00519     m_fMat[1][2] = in_matrix4[1][2];
00520     m_fMat[1][3] = in_matrix4[1][3];
00521     m_fMat[2][0] = in_matrix4[2][0];
00522     m_fMat[2][1] = in_matrix4[2][1];
00523     m_fMat[2][2] = in_matrix4[2][2];
00524     m_fMat[2][3] = in_matrix4[2][3];
00525     m_fMat[3][0] = in_matrix4[3][0];
00526     m_fMat[3][1] = in_matrix4[3][1];
00527     m_fMat[3][2] = in_matrix4[3][2];
00528     m_fMat[3][3] = in_matrix4[3][3];
00529 }
00530 
00531 SICPPSDK_INLINE float* CMatrix4f::Get()
00532 {
00533     return &m_fMat[0][0];
00534 }
00535 
00536 SICPPSDK_INLINE float CMatrix4f::GetValue(short in_sRow,short in_sCol ) const
00537 {
00538     bool l_bValidIndex =  ( in_sRow >=0 && in_sCol >= 0 &&
00539                             in_sRow <=3 && in_sCol <= 3);
00540     assert(l_bValidIndex);
00541 
00542     if(l_bValidIndex)
00543     {
00544         return m_fMat[in_sRow][in_sCol];
00545     }
00546     return 0.0;
00547 }
00548 
00549 SICPPSDK_INLINE void CMatrix4f::SetValue(short in_sRow, short in_sCol, float in_fVal )
00550 {
00551     bool l_bValidIndex =  ( in_sRow >=0 && in_sCol >= 0 && in_sRow <=3 && in_sCol <= 3);
00552 
00553     assert(l_bValidIndex);
00554     if(l_bValidIndex)
00555     {
00556         m_fMat[in_sRow][in_sCol] = in_fVal;
00557     }
00558 }
00559 
00560 SICPPSDK_INLINE bool CMatrix4f::EpsilonEquals
00561 (
00562     const CMatrix4f& in_matrix4,
00563     float in_fEpsilon
00564 ) const
00565 {
00566     return (this == &in_matrix4) ? true :
00567         ::fabs(m_fMat[0][0] - in_matrix4.m_fMat[0][0]) < ::fabs(in_fEpsilon) &&
00568         ::fabs(m_fMat[0][1] - in_matrix4.m_fMat[0][1]) < ::fabs(in_fEpsilon) &&
00569         ::fabs(m_fMat[0][2] - in_matrix4.m_fMat[0][2]) < ::fabs(in_fEpsilon) &&
00570         ::fabs(m_fMat[0][3] - in_matrix4.m_fMat[0][3]) < ::fabs(in_fEpsilon) &&
00571         ::fabs(m_fMat[1][0] - in_matrix4.m_fMat[1][0]) < ::fabs(in_fEpsilon) &&
00572         ::fabs(m_fMat[1][1] - in_matrix4.m_fMat[1][1]) < ::fabs(in_fEpsilon) &&
00573         ::fabs(m_fMat[1][2] - in_matrix4.m_fMat[1][2]) < ::fabs(in_fEpsilon) &&
00574         ::fabs(m_fMat[1][3] - in_matrix4.m_fMat[1][3]) < ::fabs(in_fEpsilon) &&
00575         ::fabs(m_fMat[2][0] - in_matrix4.m_fMat[2][0]) < ::fabs(in_fEpsilon) &&
00576         ::fabs(m_fMat[2][1] - in_matrix4.m_fMat[2][1]) < ::fabs(in_fEpsilon) &&
00577         ::fabs(m_fMat[2][2] - in_matrix4.m_fMat[2][2]) < ::fabs(in_fEpsilon) &&
00578         ::fabs(m_fMat[2][3] - in_matrix4.m_fMat[2][3]) < ::fabs(in_fEpsilon) &&
00579         ::fabs(m_fMat[3][0] - in_matrix4.m_fMat[3][0]) < ::fabs(in_fEpsilon) &&
00580         ::fabs(m_fMat[3][1] - in_matrix4.m_fMat[3][1]) < ::fabs(in_fEpsilon) &&
00581         ::fabs(m_fMat[3][2] - in_matrix4.m_fMat[3][2]) < ::fabs(in_fEpsilon) &&
00582         ::fabs(m_fMat[3][3] - in_matrix4.m_fMat[3][3]) < ::fabs(in_fEpsilon);
00583 }
00584 
00585 SICPPSDK_INLINE bool CMatrix4f::Equals(const CMatrix4f& in_matrix4) const
00586 {
00587     return (this == &in_matrix4) ? true :
00588         m_fMat[0][0] == in_matrix4.m_fMat[0][0] &&
00589         m_fMat[0][1] == in_matrix4.m_fMat[0][1] &&
00590         m_fMat[0][2] == in_matrix4.m_fMat[0][2] &&
00591         m_fMat[0][3] == in_matrix4.m_fMat[0][3] &&
00592         m_fMat[1][0] == in_matrix4.m_fMat[1][0] &&
00593         m_fMat[1][1] == in_matrix4.m_fMat[1][1] &&
00594         m_fMat[1][2] == in_matrix4.m_fMat[1][2] &&
00595         m_fMat[1][3] == in_matrix4.m_fMat[1][3] &&
00596         m_fMat[2][0] == in_matrix4.m_fMat[2][0] &&
00597         m_fMat[2][1] == in_matrix4.m_fMat[2][1] &&
00598         m_fMat[2][2] == in_matrix4.m_fMat[2][2] &&
00599         m_fMat[2][3] == in_matrix4.m_fMat[2][3] &&
00600         m_fMat[3][0] == in_matrix4.m_fMat[3][0] &&
00601         m_fMat[3][1] == in_matrix4.m_fMat[3][1] &&
00602         m_fMat[3][2] == in_matrix4.m_fMat[3][2] &&
00603         m_fMat[3][3] == in_matrix4.m_fMat[3][3];
00604 }
00605 
00606 SICPPSDK_INLINE bool CMatrix4f::operator ==(const CMatrix4f & in_matrix4 ) const
00607 {
00608     return Equals( in_matrix4 );
00609 }
00610 
00611 SICPPSDK_INLINE bool CMatrix4f::operator !=(const CMatrix4f & in_matrix4 ) const
00612 {
00613     return ! Equals( in_matrix4 );
00614 }
00615 
00616 SICPPSDK_INLINE bool CMatrix4f::operator < (const CMatrix4f& in_matrix4 )const
00617 {
00618     if ( m_fMat[0][0] != in_matrix4.m_fMat[0][0] ) return m_fMat[0][0] < in_matrix4.m_fMat[0][0];
00619     if ( m_fMat[0][1] != in_matrix4.m_fMat[0][1] ) return m_fMat[0][1] < in_matrix4.m_fMat[0][1];
00620     if ( m_fMat[0][2] != in_matrix4.m_fMat[0][2] ) return m_fMat[0][2] < in_matrix4.m_fMat[0][2];
00621     if ( m_fMat[0][3] != in_matrix4.m_fMat[0][3] ) return m_fMat[0][3] < in_matrix4.m_fMat[0][3];
00622     if ( m_fMat[1][0] != in_matrix4.m_fMat[1][0] ) return m_fMat[1][0] < in_matrix4.m_fMat[1][0];
00623     if ( m_fMat[1][1] != in_matrix4.m_fMat[1][1] ) return m_fMat[1][1] < in_matrix4.m_fMat[1][1];
00624     if ( m_fMat[1][2] != in_matrix4.m_fMat[1][2] ) return m_fMat[1][2] < in_matrix4.m_fMat[1][2];
00625     if ( m_fMat[1][3] != in_matrix4.m_fMat[1][3] ) return m_fMat[1][3] < in_matrix4.m_fMat[1][3];
00626     if ( m_fMat[2][0] != in_matrix4.m_fMat[2][0] ) return m_fMat[2][0] < in_matrix4.m_fMat[2][0];
00627     if ( m_fMat[2][1] != in_matrix4.m_fMat[2][1] ) return m_fMat[2][1] < in_matrix4.m_fMat[2][1];
00628     if ( m_fMat[2][2] != in_matrix4.m_fMat[2][2] ) return m_fMat[2][2] < in_matrix4.m_fMat[2][2];
00629     if ( m_fMat[2][3] != in_matrix4.m_fMat[2][3] ) return m_fMat[2][3] < in_matrix4.m_fMat[2][3];
00630     if ( m_fMat[3][0] != in_matrix4.m_fMat[3][0] ) return m_fMat[3][0] < in_matrix4.m_fMat[3][0];
00631     if ( m_fMat[3][1] != in_matrix4.m_fMat[3][1] ) return m_fMat[3][1] < in_matrix4.m_fMat[3][1];
00632     if ( m_fMat[3][2] != in_matrix4.m_fMat[3][2] ) return m_fMat[3][2] < in_matrix4.m_fMat[3][2];
00633     if ( m_fMat[3][3] != in_matrix4.m_fMat[3][3] ) return m_fMat[3][3] < in_matrix4.m_fMat[3][3];
00634     return false;
00635 }
00636 
00637 SICPPSDK_INLINE bool CMatrix4f::ComputeInverse
00638 (
00639     const float in_fMat[4][4],
00640     float out_fInv[4][4],
00641     const bool bTransposeResult
00642 )
00643 {
00644     int     i, j, k;
00645     float   fSys[4][8];
00646     float   fTemp;
00647 
00648     // Initialize fSys matrix:
00649     for(i=0; i<4; i++)
00650     {
00651         for(j=0; j<4; j++)
00652         {
00653             fSys[i][j] = in_fMat[i][j];
00654             fSys[i][j+4] = (float) (i==j);
00655         }
00656     }
00657     // Compute inverse:
00658     for(j=0; j<4; j++)
00659     {
00660         if(fabs(fSys[j][j]) < MicroEPS)
00661         {
00662             for(i=j + 1; (i<4) && (fabs(fSys[i][j]) < MicroEPS ); i++)
00663             {};
00664             if(i==4)
00665             {
00666                 return(false);
00667             }
00668             else
00669             {
00670                 for(k=0; k<8; k++)
00671                 {
00672                     fTemp = fSys[i][k];
00673                     fSys[i][k] = fSys[j][k];
00674                     fSys[j][k] = fTemp;
00675                 }
00676             }
00677         }
00678         fTemp = 1.0f / fSys[j][j];
00679         for(i=0; i<8; i++)
00680         {
00681             fSys[j][i] *= fTemp;
00682         }
00683         for(i=0; i<4; i++)
00684         {
00685             if(i != j)
00686             {
00687                 fTemp = - fSys[i][j];
00688                 for(k=0; k<8; k++)
00689                 {
00690                     fSys[i][k] += fSys[j][k] * fTemp;
00691                 }
00692             }
00693         }
00694     }
00695 
00696     // Copy result from fSys to out_fInv:
00697     if(bTransposeResult)
00698     {
00699         for(i=0; i<4; i++)
00700         {
00701             for(j=0; j<4; j++)
00702             {
00703                 out_fInv[j][i] = fSys[i][j + 4];
00704             }
00705         }
00706     }
00707     else
00708     {
00709         for(i=0; i<4; i++)
00710         {
00711             for(j=0; j<4; j++)
00712             {
00713                 out_fInv[i][j] = fSys[i][j + 4];
00714             }
00715         }
00716     }
00717     return(true);
00718 }
00719 
00720 };
00721 };
00722 
00723 #endif // __XSIMATRIX4_H__