Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

Matrix3C.h

00001 //-------------------------------------------------------------------------
00002 //
00003 // File:        Matrix3C.h
00004 // Desc:        3x4 matrix class.
00005 // Author:      memon <memon@inside.org>
00006 //
00007 //-------------------------------------------------------------------------
00008 //  Copyright (c) 2000-2002 Moppi Productions. All Rights Reserved.
00009 //  This file is part of Moppi Demopaja SDK. For conditions of 
00010 //  distribution and use, see the accompanying license.txt file.
00011 //  http://moppi.inside.org/demopaja/
00012 //-------------------------------------------------------------------------
00013 
00014 #ifndef __DEMOPAJA_MATRIX3_H__
00015 #define __DEMOPAJA_MATRIX3_H__
00016 
00017 #if _MSC_VER >= 1000
00018 #pragma once
00019 #endif // _MSC_VER >= 1000
00020 
00021 
00022 #include "PajaTypes.h"
00023 #include "Vector3C.h"
00024 #include "QuatC.h"
00025 
00026 namespace PajaTypes {
00027 
00028     class QuatC;
00029 
00031 
00037     class Matrix3C {
00038     public:
00039 
00041         Matrix3C();
00042 
00044         Matrix3C( const Matrix3C& rMat );
00045 
00047 
00051         Matrix3C( const float32* pMat );
00052 
00054         virtual ~Matrix3C();
00055 
00057         Matrix3C            operator-() const;
00058 
00060         Matrix3C&           operator-=( const Matrix3C& rMat );
00061         
00063         Matrix3C&           operator+=( const Matrix3C& rMat );
00064         
00066         Matrix3C            operator-( const Matrix3C& rMat ) const;
00067 
00069         Matrix3C            operator+( const Matrix3C& rMat ) const;
00070 
00072         Matrix3C            operator*( const Matrix3C& rMat ) const;
00073 
00075         Matrix3C&           operator*=( const Matrix3C& rMat );
00076 
00078 
00081         Vector3C&           operator[]( int32 i );
00082 
00084 
00087         const Vector3C&     operator[]( int32 i ) const;
00088 
00090         friend Vector3C     operator*( const Matrix3C& rMat, const Vector3C& rVec );
00091         
00093         friend Vector3C     operator*( const Vector3C& rVec, const Matrix3C& rMat );
00094         
00096         friend Vector3C&    operator*=( Vector3C& rVec, const Matrix3C& rMat );
00097 
00099         Matrix3C&   set_identity();
00100 
00102         Matrix3C&   set_trans( const Vector3C& v );
00103 
00105         Matrix3C&   set_scale( const Vector3C& v );
00106 
00108         Matrix3C&   set_rot_x( float32 f32Angle );
00109         
00111         Matrix3C&   set_rot_y( float32 f32Angle );
00112 
00114         Matrix3C&   set_rot_z( float32 f32Angle );
00115         
00117         Matrix3C&   set_rot_xyz( float32 f32XAngle, float32 f32YAngle, float32 f32ZAngle );
00118 
00120         Matrix3C&   set_rot( const QuatC& rQuat );
00121 
00123         Matrix3C    pre_trans( const Vector3C& rVec ) const;
00124 
00126         Matrix3C    inverse() const;
00127 
00129         Matrix3C    transpose() const;
00130 
00132         Matrix3C    ortho_norm() const;
00133 
00134 
00135     private:
00136         Vector3C    m_rMat[4];
00137     };
00138 
00139 
00140 
00141     //
00142     // Inlines
00143     //
00144 
00145     inline
00146     Vector3C&
00147     Matrix3C::operator[]( int i )
00148     {
00149         assert( i >= 0 && i < 4 );
00150         return m_rMat[i];
00151     }
00152 
00153     inline
00154     const Vector3C&
00155     Matrix3C::operator[]( int i ) const
00156     {
00157         assert( i >= 0 && i < 4 );
00158         return m_rMat[i];
00159     }
00160 
00161     inline
00162     Vector3C
00163     operator*( const Matrix3C& m, const Vector3C& v )
00164     {
00165         return Vector3C( v[0] * m[0][0] + v[1] * m[1][0] + v[2] * m[2][0] + m[3][0],
00166                          v[0] * m[0][1] + v[1] * m[1][1] + v[2] * m[2][1] + m[3][1],
00167                          v[0] * m[0][2] + v[1] * m[1][2] + v[2] * m[2][2] + m[3][2] );
00168     }
00169 
00170     inline
00171     Vector3C
00172     operator*( const Vector3C& v, const Matrix3C& m )
00173     {
00174         return Vector3C( v[0] * m[0][0] + v[1] * m[1][0] + v[2] * m[2][0] + m[3][0],
00175                          v[0] * m[0][1] + v[1] * m[1][1] + v[2] * m[2][1] + m[3][1],
00176                          v[0] * m[0][2] + v[1] * m[1][2] + v[2] * m[2][2] + m[3][2] );
00177     }
00178 
00179     inline
00180     Vector3C&
00181     operator*=( Vector3C& v, const Matrix3C& m )
00182     {
00183         Vector3C    rTmp = v;
00184         v[0] = rTmp[0] * m[0][0] + rTmp[1] * m[1][0] + rTmp[2] * m[2][0] + m[3][0];
00185         v[1] = rTmp[0] * m[0][1] + rTmp[1] * m[1][1] + rTmp[2] * m[2][1] + m[3][1];
00186         v[2] = rTmp[0] * m[0][2] + rTmp[1] * m[1][2] + rTmp[2] * m[2][2] + m[3][2];
00187         return v;
00188     }
00189 
00190 };  // namespace PajaTypes
00191 
00192 #endif

Moppi Demopaja SDK Documentation -- Copyright © 2000-2002 Moppi Productions