00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef CEYLAN_MATRIX_2_H_
00028 #define CEYLAN_MATRIX_2_H_
00029
00030
00031 #include "CeylanVector2.h"
00032 #include "CeylanMatrix.h"
00033 #include "CeylanLinear.h"
00034
00035 #include <string>
00036
00037
00038
00039
00040 namespace Ceylan
00041 {
00042
00043
00044 namespace Maths
00045 {
00046
00047
00048 namespace Linear
00049 {
00050
00051
00052
00053
00054 class Bipoint ;
00055
00056
00057
00058 class Vector2 ;
00059
00060
00061
00078 class CEYLAN_DLL Matrix2: public Matrix
00079 {
00080
00081
00082
00083
00084
00086 friend class Bipoint ;
00087
00088
00090 friend class Vector2 ;
00091
00092
00093
00105 CEYLAN_DLL friend bool operator == ( const Matrix2 & m1,
00106 const Matrix2 & m2 ) ;
00107
00108
00109
00120 CEYLAN_DLL friend bool operator != ( const Matrix2 & m1,
00121 const Matrix2 & m2 ) ;
00122
00123
00124
00129 CEYLAN_DLL friend Matrix2 operator + ( const Matrix2 & m1,
00130 const Matrix2 & m2 ) ;
00131
00132
00133
00138 CEYLAN_DLL friend Matrix2 operator - ( const Matrix2 & m1,
00139 const Matrix2 & m2 ) ;
00140
00141
00142
00147 CEYLAN_DLL friend Matrix2 operator * ( const Matrix2 & m1,
00148 const Matrix2 & m2 ) ;
00149
00150
00151
00156 CEYLAN_DLL friend Matrix2 operator * ( Real lambda,
00157 const Matrix2 & m ) ;
00158
00159
00160
00168 CEYLAN_DLL friend Matrix2 operator ! ( const Matrix2 & m ) ;
00169
00170
00171
00177 CEYLAN_DLL friend Matrix2 operator ~ ( const Matrix2 & m ) ;
00178
00179
00180
00185 CEYLAN_DLL friend Vector2 operator * ( const Matrix2 & m ,
00186 const Vector2 & v ) ;
00187
00188
00189
00190
00191 public:
00192
00193
00194
00202 explicit Matrix2( Real x0 = 0, Real x1 = 0,
00203 Real y0 = 0, Real y1 = 0 ) ;
00204
00205
00206
00215 Matrix2( const Matrix2 & source ) ;
00216
00217
00218
00220 virtual ~Matrix2() throw() ;
00221
00222
00223
00228 virtual void setTo( Real x0 = 0, Real x1 = 0,
00229 Real y0 = 0, Real y1 = 0 ) ;
00230
00231
00232
00239 virtual void setColumn( MatrixIndex columnNumber,
00240 const Vector2 & newColumn ) ;
00241
00242
00243
00249 virtual void setAllElementsTo( Real commonValue ) ;
00250
00251
00252
00262 virtual Real getElementAt( MatrixIndex abscissa,
00263 MatrixIndex ordinate ) const ;
00264
00265
00266
00276 virtual void setElementAt( MatrixIndex abscissa,
00277 MatrixIndex ordinate, Real newValue ) ;
00278
00279
00280
00282 virtual void setToIdentity() ;
00283
00284
00285
00291 virtual void setToDiagonal( Real diagonalTerm ) ;
00292
00293
00294
00296 virtual void transpose() ;
00297
00298
00299
00301 virtual Real trace() const ;
00302
00303
00304
00306 virtual Real determinant() const ;
00307
00308
00309
00322 virtual const std::string toString(
00323 VerbosityLevels level = high ) const ;
00324
00325
00326
00327
00328
00329
00330
00331
00333 static Matrix2 Cofactor( const Matrix2 & m ) ;
00334
00335
00336
00338 static Matrix2 Adjoint( const Matrix2 & m ) ;
00339
00340
00341
00349 static Matrix2 CreateFromRotation( AngleInDegrees angle ) ;
00350
00351
00352
00364 template<typename T>
00365 static Matrix2 CreateFrom( T endomorphism )
00366 {
00367
00368 Matrix2 result ;
00369
00370 Vector2 v( 1, 0 ) ;
00371 v = endomorphism( v ) ;
00372 result.setColumn( 0, v ) ;
00373
00374 v.setTo( 0 ,1 ) ;
00375 v = endomorphism( v ) ;
00376 result.setColumn( 1, v ) ;
00377
00378 return result ;
00379
00380 }
00381
00382
00387 static const MatrixIndex Dimensions = 2 ;
00388
00389
00390
00391 protected:
00392
00393
00395 Real _mat[ Dimensions ][ Dimensions ] ;
00396
00397
00398
00399 } ;
00400
00401
00402
00403
00404
00405
00406
00407
00408 CEYLAN_DLL Matrix2 operator ! ( const Matrix2 & m ) ;
00409
00410
00411 }
00412
00413 }
00414
00415 }
00416
00417
00418 #endif // CEYLAN_MATRIX_2_H_
00419