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

Matrix2C.h

00001 //-------------------------------------------------------------------------
00002 //
00003 // File:        Matrix2C.h
00004 // Desc:        2x3 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_MATRIX2C_H__
00015 #define __DEMOPAJA_MATRIX2C_H__
00016 
00017 #include "Vector2C.h"
00018 #include "PajaTypes.h"
00019 
00020 
00021 namespace PajaTypes {
00022 
00024 
00030     class Matrix2C {
00031     public:
00033         Matrix2C();
00034 
00036         Matrix2C( const Matrix2C& rMat );
00037 
00039 
00043         Matrix2C( const float32* pMat );
00044 
00046         virtual ~Matrix2C();
00047   
00049         Matrix2C    operator*( const Matrix2C& rMat ) const;
00050 
00052         Matrix2C&   operator*=( const Matrix2C& rMat );
00053 
00055 
00059         Vector2C&           operator[]( int32 i );
00060 
00062 
00065         const Vector2C&     operator[]( int32 i ) const;
00066 
00068         Matrix2C            operator-() const;
00069 
00071         Matrix2C&           operator-=( const Matrix2C& rMat );
00072         
00074         Matrix2C&           operator+=( const Matrix2C& rMat );
00075         
00077         Matrix2C            operator-( const Matrix2C& rMat ) const;
00078 
00080         Matrix2C            operator+( const Matrix2C& rMat ) const;
00081 
00083         friend Vector2C     operator*( const Matrix2C& rMat, const Vector2C& rVec );
00084         
00086         friend Vector2C     operator*( const Vector2C& rVec, const Matrix2C& rMat );
00087         
00089         friend Vector2C&    operator*=( Vector2C& rVec, const Matrix2C& rMat );
00090         
00092         Matrix2C&   set_identity();
00093 
00095         Matrix2C&   set_trans( const Vector2C& rVec );
00096 
00098         Matrix2C&   set_scale( const Vector2C& rVec );
00099 
00101         Matrix2C&   set_rot( float32 f32Angle );
00102 
00104         Matrix2C    pre_trans( const Vector2C& rVec ) const;
00105 
00107         Matrix2C    invert() const;
00108 
00110         Matrix2C    transpose() const;
00111 
00113         Matrix2C    ortho_norm() const;
00114 
00115     private:
00116         Vector2C    m_rMat[3];
00117 
00118     };
00119 
00120 
00121 
00122     inline
00123     Vector2C&
00124     Matrix2C::operator[]( int32 i )
00125     {
00126         assert( i >= 0 || i < 3 );
00127         return m_rMat[i];
00128     }
00129 
00130     inline
00131     const Vector2C&
00132     Matrix2C::operator[]( int32 i ) const
00133     {
00134         assert( i >= 0 || i < 3 );
00135         return m_rMat[i];
00136     }
00137 
00138 
00139     inline
00140     Vector2C
00141     operator*( const Matrix2C& m, const Vector2C& v )
00142     {
00143         return Vector2C( v[0] * m[0][0] + v[1] * m[1][0] + m[2][0],
00144                          v[0] * m[0][1] + v[1] * m[1][1] + m[2][1] );
00145     }
00146 
00147     inline
00148     Vector2C
00149     operator*( const Vector2C& v, const Matrix2C& m )
00150     {
00151         return Vector2C( v[0] * m[0][0] + v[1] * m[1][0] + m[2][0],
00152                          v[0] * m[0][1] + v[1] * m[1][1] + m[2][1] );
00153     }
00154 
00155     inline
00156     Vector2C&
00157     operator*=( Vector2C& v, const Matrix2C& m )
00158     {
00159         Vector2C    temp( v[0] * m[0][0] + v[1] * m[1][0] + m[2][0],
00160                           v[0] * m[0][1] + v[1] * m[1][1] + m[2][1] );
00161         v = temp;
00162         return v;
00163     }
00164 
00165 };  // namespace
00166 
00167 #endif

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