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

quat.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 // Quaternion-math borrowed from plib http://plib.sourceforge.net/index.html
00024 // Which is covered by LGPL2
00025 // And has this additional copyright note:
00026 /*
00027  Quaternion routines are Copyright (C) 1999
00028  Kevin B. Thompson <kevinbthompson@yahoo.com>
00029  Modified by Sylvan W. Clebsch <sylvan@stanford.edu>
00030  Largely rewritten by "Negative0" <negative0@earthlink.net>
00031  */
00032 
00033 #ifndef MATH_QUAT_H
00034 #define MATH_QUAT_H
00035 
00036 #include "common/scummsys.h"
00037 #include "common/endian.h"
00038 
00039 #include "math/rotation3d.h"
00040 #include "math/vector.h"
00041 #include "math/angle.h"
00042 #include "math/vector4d.h"
00043 #include "math/matrix4.h"
00044 
00045 namespace Math {
00046 
00047 class Quaternion : public Vector4d {
00048 public:
00052     Quaternion() : Vector4d(0, 0, 0, 1.0) {}
00053 
00062     Quaternion(float lx, float ly, float lz, float lw) : Vector4d(lx, ly, lz, lw) {}
00063 
00069     Quaternion(const Quaternion &q) : Vector4d(q.x(), q.y(), q.z(), q.w()) {} 
00070 
00077     Quaternion(const Vector4d &vec) : Vector4d(vec.x(), vec.y(), vec.z(), vec.w()) {}
00078 
00084     Quaternion(const Matrix3 &m);
00085 
00091     Quaternion(const Matrix4 &m);
00092 
00096     void fromMatrix(const Matrix3 &m);
00097 
00104     Quaternion(const Vector3d &axis, const Angle &angle);
00105 
00114     static Quaternion fromEuler(const Angle &first, const Angle &second, const Angle &third, EulerOrder order);
00115 
00124     void getEuler(Angle *first, Angle *second, Angle *third, EulerOrder order) const;
00125 
00131     static Quaternion xAxis(const Angle &angle);
00132 
00138     static Quaternion yAxis(const Angle &angle);
00139 
00145     static Quaternion zAxis(const Angle &angle);
00146 
00151     Quaternion &normalize();
00152 
00157     void transform(Vector3d &v) const;
00158 
00163     Matrix4 toMatrix() const;
00164 
00169     void toMatrix(Matrix4 &dst) const;
00170 
00175     Quaternion inverse() const;
00176 
00183     Quaternion slerpQuat(const Quaternion& to, const float t) const;
00184 
00190     Vector3d directionVector(const int col) const;
00191 
00197     Angle getAngleBetween(const Quaternion &to);
00198 
00204     Quaternion& operator=(Vector4d &vec);
00205 
00211     Quaternion operator*(const Quaternion &quat) const;
00212     Quaternion& operator*=(const Quaternion &quat);
00213 
00219     Quaternion operator*(const float c) const;
00220 
00226     Quaternion operator+(const Quaternion &o) const;
00227     Quaternion& operator+=(const Quaternion &o);
00228 
00234     bool operator==(const Quaternion &o) const;
00235     bool operator!=(const Quaternion &o) const;
00236 };
00237 
00238 } // end of namespace Math
00239 
00240 #endif


Generated on Sat Sep 14 2019 05:01:35 for ResidualVM by doxygen 1.7.1
curved edge   curved edge