00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 00006 00007 Copyright © 2000-2002 The OGRE Team 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 ----------------------------------------------------------------------------- 00024 */ 00025 #include "OgreStableHeaders.h" 00026 #include "OgreMatrix4.h" 00027 00028 #include "OgreVector3.h" 00029 #include "OgreMatrix3.h" 00030 00031 namespace Ogre 00032 { 00033 00034 const Matrix4 Matrix4::ZERO( 00035 0, 0, 0, 0, 00036 0, 0, 0, 0, 00037 0, 0, 0, 0, 00038 0, 0, 0, 0 ); 00039 00040 const Matrix4 Matrix4::IDENTITY( 00041 1, 0, 0, 0, 00042 0, 1, 0, 0, 00043 0, 0, 1, 0, 00044 0, 0, 0, 1 ); 00045 00046 00047 inline Real 00048 MINOR(const Matrix4& m, const int r0, const int r1, const int r2, const int c0, const int c1, const int c2) 00049 { 00050 return m[r0][c0] * (m[r1][c1] * m[r2][c2] - m[r2][c1] * m[r1][c2]) - 00051 m[r0][c1] * (m[r1][c0] * m[r2][c2] - m[r2][c0] * m[r1][c2]) + 00052 m[r0][c2] * (m[r1][c0] * m[r2][c1] - m[r2][c0] * m[r1][c1]); 00053 } 00054 00055 00056 Matrix4 Matrix4::adjoint() const 00057 { 00058 return Matrix4( MINOR(*this, 1, 2, 3, 1, 2, 3), 00059 -MINOR(*this, 0, 2, 3, 1, 2, 3), 00060 MINOR(*this, 0, 1, 3, 1, 2, 3), 00061 -MINOR(*this, 0, 1, 2, 1, 2, 3), 00062 00063 -MINOR(*this, 1, 2, 3, 0, 2, 3), 00064 MINOR(*this, 0, 2, 3, 0, 2, 3), 00065 -MINOR(*this, 0, 1, 3, 0, 2, 3), 00066 MINOR(*this, 0, 1, 2, 0, 2, 3), 00067 00068 MINOR(*this, 1, 2, 3, 0, 1, 3), 00069 -MINOR(*this, 0, 2, 3, 0, 1, 3), 00070 MINOR(*this, 0, 1, 3, 0, 1, 3), 00071 -MINOR(*this, 0, 1, 2, 0, 1, 3), 00072 00073 -MINOR(*this, 1, 2, 3, 0, 1, 2), 00074 MINOR(*this, 0, 2, 3, 0, 1, 2), 00075 -MINOR(*this, 0, 1, 3, 0, 1, 2), 00076 MINOR(*this, 0, 1, 2, 0, 1, 2)); 00077 } 00078 00079 00080 Real Matrix4::determinant() const 00081 { 00082 return m[0][0] * MINOR(*this, 1, 2, 3, 1, 2, 3) - 00083 m[0][1] * MINOR(*this, 1, 2, 3, 0, 2, 3) + 00084 m[0][2] * MINOR(*this, 1, 2, 3, 0, 1, 3) - 00085 m[0][3] * MINOR(*this, 1, 2, 3, 0, 1, 2); 00086 } 00087 00088 Matrix4 Matrix4::inverse() const 00089 { 00090 return adjoint() * (1.0f / determinant()); 00091 } 00092 00093 }
Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:17 2004