Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

Matrix4By4 Class Reference

#include <Matrix44.hpp>

List of all members.

Public Methods

 Matrix4By4 ()
 Matrix4By4 (const double a1_1, const double a1_2, const double a1_3, const double a2_1, const double a2_2, const double a2_3, const double a3_1, const double a3_2, const double a3_3, const double Xt, const double Yt, const double Zt)
 Matrix4By4 (const Matrix4By4 &m)
double operator[] (const tJ2KMath::EMatrixElems eElem) const
void operator *= (const Matrix4By4 &m)
BOOL operator== (const Matrix4By4 &m) const
BOOL operator!= (const Matrix4By4 &m) const
Matrix4By4 & operator= (const Matrix4By4 &m)
void AppendRotation (const double XAngle, const double YAngle, const double ZAngle)
void AppendRotation (const Vector3D &vecAngles)
void AppendScale (const double XScale, const double YScale, const double ZScale)
void AppendScale (const Vector3D &vecScale)
void AppendTranslation (const double XTrans, const double YTrans, const double ZTrans)
void AppendTranslation (const Vector3D &vecTrans)
void SetToIdentity ()
void SetToRotation (const double XDeg, const double YDeg, const double ZDeg)
void SetToRotation (const Vector3D &vecAngles)
void SetToScale (const double XScale, const double YScale, const double ZScale)
void SetToScale (const Vector3D &vecScale)
void SetToTranslation (const double XTrans, const double YTrans, const double ZTrans)
void SetToTranslation (const Vector3D &vecTrans)
void SetToTransposed (const Matrix4By4 &mtrxSrc)
void Transform (Vector3D &vecTarget) const
void Transform (const Vector3D &vecSource, Vector3D &vecTarget) const
void Transpose ()
void Zero ()

Friends

Matrix4By4 operator * (const Matrix4By4 &left, const Matrix4By4 &right)


Constructor & Destructor Documentation

Matrix4By4::Matrix4By4   [inline]
 

Definition at line 1 of file Matrix44.cpp.

00001                               {
00002     SetToIdentity();
00003 }

Matrix4By4::Matrix4By4 const double    a1_1,
const double    a1_2,
const double    a1_3,
const double    a2_1,
const double    a2_2,
const double    a2_3,
const double    a3_1,
const double    a3_2,
const double    a3_3,
const double    Xt,
const double    Yt,
const double    Zt
 

Definition at line 45 of file Matrix44.cpp.

00050 {
00051     TRawMem::SetMemBuf(jMatrix, j2klib::TCard1(0), sizeof(jMatrix));
00052     jMatrix[0][0]     = a1_1;
00053     jMatrix[0][1]     = a1_2;
00054     jMatrix[0][2]     = a1_3;
00055     jMatrix[1][0]     = a2_1;
00056     jMatrix[1][1]     = a2_2;
00057     jMatrix[1][2]     = a2_3;
00058     jMatrix[2][0]     = a3_1;
00059     jMatrix[2][1]     = a3_2;
00060     jMatrix[2][2]     = a3_3;
00061     jMatrix[3][0]     = Xt;
00062     jMatrix[3][1]     = Yt;
00063     jMatrix[3][2]     = Zt;
00064 }

Matrix4By4::Matrix4By4 const Matrix4By4 &    m
 

Definition at line 66 of file Matrix44.cpp.

00066                                             {
00067     TRawMem::CopyMemBuf(jMatrix, mtrxSrc.jMatrix, sizeof(jMatrix));
00068 }


Member Function Documentation

void Matrix4By4::AppendRotation const Vector3D   vecAngles
 

Definition at line 153 of file Matrix44.cpp.

00154 {
00155     // Get a copy of the vector and convert to radians
00156     T3DVector vecTmp(vecAngles);
00157     vecTmp.ToRadians();
00158 
00159     // Get the sine and cosine of each value
00160     double SinX, SinY, SinZ;
00161     double CosX, CosY, CosZ;
00162     SinX = TMathLib::Sine(vecTmp.X());
00163     CosX = TMathLib::Cosine(vecTmp.X());
00164     SinY = TMathLib::Sine(vecTmp.Y());
00165     CosY = TMathLib::Cosine(vecTmp.Y());
00166     SinZ = TMathLib::Sine(vecTmp.Z());
00167     CosZ = TMathLib::Cosine(vecTmp.Z());
00168 
00169     // Concatenate the X rotation
00170     Matrix4By4 mtrxTmp;
00171     mtrxTmp[tJ2KMath::EMatrix_22] = CosX;
00172     mtrxTmp[tJ2KMath::EMatrix_33] = CosX;
00173     mtrxTmp[tJ2KMath::EMatrix_23] = SinX;
00174     mtrxTmp[tJ2KMath::EMatrix_32] = -SinX;
00175     *this *= mtrxTmp;
00176 
00177     // Concatenate the Y rotation
00178     mtrxTmp.SetToIdentity();
00179     mtrxTmp[tJ2KMath::EMatrix_11] = CosY;
00180     mtrxTmp[tJ2KMath::EMatrix_33] = CosY;
00181     mtrxTmp[tJ2KMath::EMatrix_13] = -SinY;
00182     mtrxTmp[tJ2KMath::EMatrix_31] = SinY;
00183     *this *= mtrxTmp;
00184 
00185     // Concatenate the Z rotation
00186     mtrxTmp.SetToIdentity();
00187     mtrxTmp[tJ2KMath::EMatrix_11] = CosZ;
00188     mtrxTmp[tJ2KMath::EMatrix_22] = CosZ;
00189     mtrxTmp[tJ2KMath::EMatrix_12] = SinZ;
00190     mtrxTmp[tJ2KMath::EMatrix_21] = -SinZ;
00191     *this *= mtrxTmp;
00192 }

void Matrix4By4::AppendRotation const double    XAngle,
const double    YAngle,
const double    ZAngle
 

Definition at line 195 of file Matrix44.cpp.

Referenced by SetToRotation().

00198 {
00199     // Convert the angles to radians
00200     double XA = XAngle * kJ2KLib::PI / 180.0;
00201     double YA = YAngle * kJ2KLib::PI / 180.0;
00202     double ZA = ZAngle * kJ2KLib::PI / 180.0;
00203 
00204     // Get the sine and cosine of each value
00205     double SinX, SinY, SinZ;
00206     double CosX, CosY, CosZ;
00207     SinX = TMathLib::Sine(XA);
00208     CosX = TMathLib::Cosine(XA);
00209     SinY = TMathLib::Sine(YA);
00210     CosY = TMathLib::Cosine(YA);
00211     SinZ = TMathLib::Sine(ZA);
00212     CosZ = TMathLib::Cosine(ZA);
00213 
00214     // Concatenate the X rotation
00215     Matrix4By4 mtrxTmp;
00216     mtrxTmp[tJ2KMath::EMatrix_22] = CosX;
00217     mtrxTmp[tJ2KMath::EMatrix_33] = CosX;
00218     mtrxTmp[tJ2KMath::EMatrix_23] = SinX;
00219     mtrxTmp[tJ2KMath::EMatrix_32] = -SinX;
00220     *this *= mtrxTmp;
00221 
00222     // Concatenate the Y rotation
00223     mtrxTmp.SetToIdentity();
00224     mtrxTmp[tJ2KMath::EMatrix_11] = CosY;
00225     mtrxTmp[tJ2KMath::EMatrix_33] = CosY;
00226     mtrxTmp[tJ2KMath::EMatrix_13] = -SinY;
00227     mtrxTmp[tJ2KMath::EMatrix_31] = SinY;
00228     *this *= mtrxTmp;
00229 
00230     // Concatenate the Z rotation
00231     mtrxTmp.SetToIdentity();
00232     mtrxTmp[tJ2KMath::EMatrix_11] = CosZ;
00233     mtrxTmp[tJ2KMath::EMatrix_22] = CosZ;
00234     mtrxTmp[tJ2KMath::EMatrix_12] = SinZ;
00235     mtrxTmp[tJ2KMath::EMatrix_21] = -SinZ;
00236     *this *= mtrxTmp;
00237 }

void Matrix4By4::AppendScale const Vector3D   vecScale
 

Definition at line 240 of file Matrix44.cpp.

00241 {
00242     // Create a temporary matrix and set up the scaling
00243     Matrix4By4 mtrxTmp;
00244     mtrxTmp[tJ2KMath::EMatrix_11] = vecScale.X();
00245     mtrxTmp[tJ2KMath::EMatrix_22] = vecScale.Y();
00246     mtrxTmp[tJ2KMath::EMatrix_33] = vecScale.Z();
00247 
00248     // Concatenate it
00249     *this *= mtrxTmp;
00250 }

void Matrix4By4::AppendScale const double    XScale,
const double    YScale,
const double    ZScale
 

Definition at line 253 of file Matrix44.cpp.

Referenced by SetToScale().

00256 {
00257     // Create a temporary matrix and set up the scaling
00258     Matrix4By4    mtrxTmp;
00259     mtrxTmp[tJ2KMath::EMatrix_11] = XScale;
00260     mtrxTmp[tJ2KMath::EMatrix_22] = YScale;
00261     mtrxTmp[tJ2KMath::EMatrix_33] = ZScale;
00262 
00263     // Concatenate it
00264     *this *= mtrxTmp;
00265 }

void Matrix4By4::AppendTranslation const Vector3D   vecTrans
 

Definition at line 268 of file Matrix44.cpp.

00269 {
00270     // Create a temporary matrix and set up the translation
00271     Matrix4By4 mtrxTmp;
00272     mtrxTmp[tJ2KMath::EMatrix_Xt] = vecTrans.X();
00273     mtrxTmp[tJ2KMath::EMatrix_Yt] = vecTrans.Y();
00274     mtrxTmp[tJ2KMath::EMatrix_Zt] = vecTrans.Z();
00275 
00276     // Concatenate it
00277     *this *= mtrxTmp;
00278 }

void Matrix4By4::AppendTranslation const double    XTrans,
const double    YTrans,
const double    ZTrans
 

Definition at line 281 of file Matrix44.cpp.

Referenced by SetToTranslation().

00284 {
00285     // Create a temporary matrix and set up the translation
00286     Matrix4By4 mtrxTmp;
00287     mtrxTmp[tJ2KMath::EMatrix_Xt] = XTrans;
00288     mtrxTmp[tJ2KMath::EMatrix_Yt] = YTrans;
00289     mtrxTmp[tJ2KMath::EMatrix_Zt] = ZTrans;
00290 
00291     // Concatenate it
00292     *this *= mtrxTmp;
00293 }

void Matrix4By4::SetToIdentity  
 

Definition at line 296 of file Matrix44.cpp.

Referenced by AppendRotation(), Matrix4By4(), SetToRotation(), SetToScale(), and SetToTranslation().

00297 {
00298     TRawMem::SetMemBuf(jMatrix, j2klib::TCard1(0), sizeof(jMatrix));
00299     jMatrix[0][0]   = 1.0;
00300     jMatrix[1][1]   = 1.0;
00301     jMatrix[2][2]   = 1.0;
00302     jMatrix[3][3]   = 1.0;
00303 }

void Matrix4By4::SetToRotation const Vector3D   vecAngles [inline]
 

Definition at line 16 of file Matrix44.cpp.

00016                                                                  {
00017     SetToIdentity();
00018     AppendRotation( vecAngles );
00019 }

void Matrix4By4::SetToRotation const double    XDeg,
const double    YDeg,
const double    ZDeg
[inline]
 

Definition at line 9 of file Matrix44.cpp.

00011                                                            {
00012     SetToIdentity();
00013     AppendRotation( XDeg, YDeg, ZDeg );
00014 }

void Matrix4By4::SetToScale const Vector3D   vecScale [inline]
 

Definition at line 28 of file Matrix44.cpp.

00028                                                              {
00029     SetToIdentity();
00030     AppendScale( vecScale );
00031 }

void Matrix4By4::SetToScale const double    XScale,
const double    YScale,
const double    ZScale
[inline]
 

Definition at line 21 of file Matrix44.cpp.

00023                                                           {
00024     SetToIdentity();
00025     AppendScale( XScale, YScale, ZScale );
00026 }

void Matrix4By4::SetToTranslation const Vector3D   vecTrans [inline]
 

Definition at line 40 of file Matrix44.cpp.

00040                                                                  {
00041     SetToIdentity();
00042     AppendTranslation( vecTrans );
00043 }

void Matrix4By4::SetToTranslation const double    XTrans,
const double    YTrans,
const double    ZTrans
[inline]
 

Definition at line 33 of file Matrix44.cpp.

00035                                                                 {
00036     SetToIdentity();
00037     AppendTranslation( XTrans, YTrans, ZTrans );
00038 }

void Matrix4By4::SetToTransposed const Matrix4By4 &    mtrxSrc
 

Definition at line 306 of file Matrix44.cpp.

00307 {
00308     // Flip the order of the indices
00309     for (j2klib::TInt4 i4Outer = 0; i4Outer < 4; i4Outer++)
00310     {
00311   for (j2klib::TInt4 i4Inner = 0; i4Inner < 4; i4Inner++)
00312   {
00313       jMatrix[i4Outer][i4Inner]
00314           = mtrxSrc.jMatrix[i4Inner][i4Outer];
00315   }
00316     }
00317 }

void Matrix4By4::Transform const Vector3D   vecSource,
Vector3D   vecTarget
const
 

Definition at line 345 of file Matrix44.cpp.

00346 {
00347     vecTarget.XMag =
00348     (
00349   (vecSource.XMag * jMatrix[0][0])
00350   + (vecSource.YMag * jMatrix[1][0])
00351   + (vecSource.ZMag * jMatrix[2][0])
00352   + jMatrix[3][0]
00353     );
00354 
00355     vecTarget.YMag = 
00356     (
00357   (vecSource.XMag * jMatrix[0][1])
00358   + (vecSource.YMag * jMatrix[1][1])
00359   + (vecSource.ZMag * jMatrix[2][1])
00360   + jMatrix[3][1]
00361     );
00362 
00363     vecTarget.ZMag =
00364     (
00365   (vecSource.XMag * jMatrix[0][2])
00366   + (vecSource.YMag * jMatrix[1][2])
00367   + (vecSource.ZMag * jMatrix[2][2])
00368   + jMatrix[3][2]
00369     );
00370 }

void Matrix4By4::Transform Vector3D   vecTarget const
 

Definition at line 320 of file Matrix44.cpp.

00321 {
00322     double X, Y, Z;
00323 
00324     X =   (vecTarget.XMag * jMatrix[0][0])
00325       + (vecTarget.YMag * jMatrix[1][0])
00326       + (vecTarget.ZMag * jMatrix[2][0])
00327       + jMatrix[3][0];
00328 
00329     Y =   (vecTarget.XMag * jMatrix[0][1])
00330       + (vecTarget.YMag * jMatrix[1][1])
00331       + (vecTarget.ZMag * jMatrix[2][1])
00332       + jMatrix[3][1];
00333 
00334     Z =   (vecTarget.XMag * jMatrix[0][2])
00335       + (vecTarget.YMag * jMatrix[1][2])
00336       + (vecTarget.ZMag * jMatrix[2][2])
00337       + jMatrix[3][2];
00338 
00339     vecTarget.XMag = X;
00340     vecTarget.YMag = Y;
00341     vecTarget.ZMag = Z;
00342 }

void Matrix4By4::Transpose  
 

Definition at line 373 of file Matrix44.cpp.

00374 {
00375     double aTmp[4][4];
00376 
00377     // Copy the current matrix to the temp array
00378     TRawMem::CopyMemBuf(aTmp, jMatrix, sizeof(jMatrix));
00379 
00380     // Now put them back in the opposite order
00381     for (j2klib::TInt4 i4Outer = 0; i4Outer < 4; i4Outer++)
00382     {
00383   for (j2klib::TInt4 i4Inner = 0; i4Inner < 4; i4Inner++)
00384       jMatrix[i4Outer][i4Inner] = aTmp[i4Inner][i4Outer];
00385     }
00386 }

void Matrix4By4::Zero  
 

Definition at line 388 of file Matrix44.cpp.

Referenced by operator *(), and operator *=().

00389 {
00390     TRawMem::SetMemBuf(jMatrix, j2klib::TCard1(0), sizeof(jMatrix));
00391 }

void Matrix4By4::operator *= const Matrix4By4 &    m
 

Definition at line 96 of file Matrix44.cpp.

00097 {
00098     // Make a copy of this matrix
00099     Matrix4By4 mtrxTmp(*this);
00100 
00101     // Zero out this matrix as the new empty matrix to fill in
00102     Zero();
00103     for (j2klib::TCard4 c4Outer = 0; c4Outer < 4; c4Outer++)
00104     {
00105   for (j2klib::TCard4 c4Inner = 0; c4Inner < 4; c4Inner++)
00106   {
00107       for (j2klib::TCard4 c4Element = 0; c4Element < 4; c4Element++)
00108       {
00109     jMatrix[c4Outer][c4Inner]
00110           += (mtrxTmp.jMatrix[c4Outer][c4Element]
00111         * mtrxSrc.jMatrix[c4Element][c4Inner]);
00112       }
00113   }
00114     }
00115 }

BOOL Matrix4By4::operator!= const Matrix4By4 &    m const [inline]
 

Definition at line 5 of file Matrix44.cpp.

00005                                                               {
00006     return !Compare( m );
00007 }

Matrix4By4 & Matrix4By4::operator= const Matrix4By4 &    mtrxToAssign
 

Definition at line 134 of file Matrix44.cpp.

00135 {
00136     if (this == &mtrxToAssign)
00137   return *this;
00138 
00139     TRawMem::CopyMemBuf
00140     (
00141   jMatrix
00142   , mtrxToAssign.jMatrix
00143   , sizeof(jMatrix)
00144     );
00145     return *this;
00146 }

BOOL Matrix4By4::operator== const Matrix4By4 &    mtrxToTest const
 

Definition at line 119 of file Matrix44.cpp.

00120 {
00121     // Compare the values of the objects
00122     if (TRawMem::eCompareMemBuf
00123     (
00124   mtrxToTest.jMatrix
00125   , jMatrix
00126   , sizeof(jMatrix)))
00127     {
00128   return FALSE;
00129     }
00130     return TRUE;
00131 }

double Matrix4By4::operator[] const tJ2KMath::EMatrixElems    eElem const
 

Definition at line 70 of file Matrix44.cpp.

00070                                                                       {
00071     return jArray[eElem];
00072 }


Friends And Related Function Documentation

Matrix4By4 operator * const Matrix4By4 &    m1,
const Matrix4By4 &    m2
[friend]
 

Definition at line 78 of file Matrix44.cpp.

00079 {
00080     Matrix4By4 mResult;
00081 
00082     mResult.Zero();
00083     for (j2klib::TCard4 c4Outer = 0; c4Outer < 4; c4Outer++)
00084     {
00085   for (j2klib::TCard4 c4Inner = 0; c4Inner < 4; c4Inner++)
00086   {
00087       for (j2klib::TCard4 c4Element = 0; c4Element < 4; c4Element++)
00088     mResult.jMatrix[c4Outer][c4Inner]
00089       += (m1.jMatrix[c4Outer][c4Element]
00090           * m2.jMatrix[c4Element][c4Inner]);
00091   }
00092     }
00093     return mResult;
00094 }


Member Data Documentation

double Matrix4By4::jArray[16] [private]
 

Definition at line 87 of file Matrix44.hpp.

double Matrix4By4::jMatrix[4][4] [private]
 

Definition at line 86 of file Matrix44.hpp.

Referenced by SetToTransposed(), operator *(), operator *=(), operator=(), and operator==().


The documentation for this class was generated from the following files:
Generated on Sun Oct 14 18:49:21 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001