Main Page   Namespace List   Class Hierarchy   Compound List   File List   Header Files   Sources   Namespace Members   Compound Members   File Members  

matrix2x2.cpp

00001 //$Header: /home/ben/Mapper/c++/RCS/matrix2x2.cpp,v 6.4 2002/07/06 17:41:50 ben Exp $
00002 // Copyright Benedict Adamson 2002.
00003 // This file is part of Mapper.
00004 
00005 // Mapper is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 2 of the License, or
00008 // (at your option) any later version.
00009 
00010 // Mapper is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 
00015 // You should have received a copy of the GNU General Public License
00016 // along with Mapper; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00027 #include "matrix2x2.h"
00028 
00029 
00030 
00031 //matrix2x2 operator* (
00032 //   const matrix2x2 &a,
00033 //   const matrix2x2 &b
00034 //   )
00035 //{
00036 //   return matrix2x2(
00037 //      a.row0.x * b.row0.x + a.row0.y * b.row1.x,
00038 //      a.row0.x * b.row0.y + a.row0.y * b.row1.y,
00039 //      a.row1.x * b.row0.x + a.row1.y * b.row1.x,
00040 //      a.row1.x * b.row0.y + a.row1.y * b.row1.y
00041 //      );
00042 //}
00043 
00044 
00045 
00046 vector2 matrix2x2::solve(
00047    const matrix2x2 &M,
00048    const vector2 &y
00049    )
00050 {
00051    //returns the x, such that M*x == y;
00052    const matrix2x2 Mi(
00053       M[1][1], -M[0][1],
00054       -M[1][0], M[0][0]
00055       );
00056    const double d = 1.0/det( M );
00057    return Mi * (d * y);
00058 }

Generated at Sun Jul 14 20:38:10 2002 for Mapper by doxygen 1.0.0 written by Dimitri van Heesch, © 1997-1999