ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

matrix3.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef MATH_MATRIX3_H
00024 #define MATH_MATRIX3_H
00025 
00026 #include "math/rotation3d.h"
00027 #include "math/squarematrix.h"
00028 #include "math/vector3d.h"
00029 
00030 namespace Math {
00031 
00032 template<>
00033 class Matrix<3, 3> : public MatrixType<3, 3>, public Rotation3D<Matrix<3, 3> > {
00034 public:
00035     Matrix();
00036     Matrix(const MatrixBase<3, 3> &m);
00037 
00038     void transpose();
00039 
00040     
00053     void buildFromTargetDir(const Math::Vector3d &modelForward, const Math::Vector3d &targetDirection, 
00054                            const Math::Vector3d &modelUp, const Math::Vector3d &worldUp);
00055 
00056     inline Matrix<3, 3> operator*(const Matrix<3, 3> &m2) const {
00057         Matrix<3, 3> result;
00058         const float *d1 = getData();
00059         const float *d2 = m2.getData();
00060         float *r = result.getData();
00061 
00062         for (int i = 0; i < 9; i += 3) {
00063             for (int j = 0; j < 3; ++j) {
00064                 r[i + j] = (d1[i + 0] * d2[j + 0])
00065                     + (d1[i + 1] * d2[j + 3])
00066                     + (d1[i + 2] * d2[j + 6]);
00067             }
00068         }
00069 
00070         return result;
00071     }
00072 };
00073 
00074 typedef Matrix<3, 3> Matrix3;
00075 
00076 } // end of namespace Math
00077 
00078 #endif
00079 


Generated on Sat Mar 16 2019 05:01:45 for ResidualVM by doxygen 1.7.1
curved edge   curved edge