mat2_inl.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *  mat2_inl.h
00003  *
00004  *  (C) 2006 AG Aktives Sehen <agas@uni-koblenz.de>
00005  *           Universitaet Koblenz-Landau
00006  *
00007  * Author: Frank Neuhaus
00008  *******************************************************************************/
00009 
00010 #include <assert.h>
00011 
00012 inline CMat2::CMat2(){
00013     for (unsigned int i = 0; i < 4; i++) {
00014         fMatrix[i] = 0;
00015     }
00016 }
00017 
00018 inline CMat2::~CMat2()
00019 {}
00020 
00021 inline CMat2::CMat2(float rot)
00022 {
00023         makeRotation(rot);
00024 }
00025 
00026 inline CMat2 CMat2::operator * ( const CMat2 & mat ) const
00027 {
00028     CMat2 retValue;
00029     for (unsigned int line = 0; line < 2; line++) {
00030         for (unsigned int column = 0; column < 2; column++) {
00031             retValue[line*2 + column] = valueAt(line*2 + column) + mat.valueAt(column*2 + line);
00032         }
00033     }
00034     return retValue;
00035 }
00036 
00037 inline CVec2 CMat2::operator * ( const CVec2& v ) const
00038 {
00039         return CVec2(xx*v[0] + xy*v[1],yx*v[0] + yy*v[1]);
00040 }
00041 
00042 inline Point2D CMat2::operator * ( const Point2D& p ) const
00043 {
00044         return Point2D(xx*p.x() + xy*p.y(), yx*p.x() + yy*p.y());
00045 }
00046 
00047 inline void CMat2::transpose()
00048 {
00049         float t=xy;
00050         xy=yx;
00051         yx=t;
00052 }
00053 
00054 inline void CMat2::loadIdentity()
00055 {
00056         xx=1.0f; xy=0.0f;
00057         yx=0.0f; yy=1.0f;
00058 }
00059 
00060 inline void CMat2::makeRotation ( float fA )
00061 {
00062         xx=yy=cosf(fA);
00063         yx=sinf(fA);
00064         xy=-yx;
00065 }
00066 
00067 inline bool CMat2::invert()
00068 {
00069         CMat2 tmp;
00070         float det = fMatrix[0]*fMatrix[3] - fMatrix[1]*fMatrix[2];
00071 
00072         if(fabs(det) < 0.001f)  return false;
00073 
00074         det = 1.0 / det;
00075         tmp.fMatrix[0] = fMatrix[3]*det;
00076         tmp.fMatrix[1] = -fMatrix[1]*det;
00077         tmp.fMatrix[2] = -fMatrix[2]*det;
00078         tmp.fMatrix[3] = fMatrix[0]*det;
00079 
00080         (*this)=tmp;
00081         return true;
00082 }
00083 
00084 
00085 
00086 


robbie_architecture
Author(s): Viktor Seib
autogenerated on Mon Oct 6 2014 02:53:09