2 This file is part of the n3dmath2 library.
4 Copyright (c) 2003 - 2005 John Tsiombikas <nuclear@siggraph.org>
6 The n3dmath2 library is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 The n3dmath2 library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with the n3dmath2 library; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * Author: John Tsiombikas 2003
24 * Modified: John Tsiombikas 2004, 2005
27 #ifndef _N3DMATH2_QUA_HPP_
28 #define _N3DMATH2_QUA_HPP_
31 #include "n3dmath2_types.hpp"
39 Quaternion(scalar_t s, const Vector3 &v);
40 Quaternion(scalar_t s, scalar_t x, scalar_t y, scalar_t z);
41 Quaternion(const Vector3 &axis, scalar_t angle);
43 Quaternion operator +(const Quaternion &quat) const;
44 Quaternion operator -(const Quaternion &quat) const;
45 Quaternion operator -() const;
46 Quaternion operator *(const Quaternion &quat) const;
48 void operator +=(const Quaternion &quat);
49 void operator -=(const Quaternion &quat);
50 void operator *=(const Quaternion &quat);
52 void reset_identity();
54 Quaternion conjugate() const;
56 scalar_t length() const;
57 scalar_t length_sq() const;
60 Quaternion normalized() const;
62 Quaternion inverse() const;
64 void set_rotation(const Vector3 &axis, scalar_t angle);
65 void rotate(const Vector3 &axis, scalar_t angle);
66 /* note: this is a totally different operation from the above
67 * this treats the quaternion as signifying direction and rotates
68 * it by a rotation quaternion by rot * q * rot'
70 void rotate(const Quaternion &q);
72 Matrix3x3 get_rotation_matrix() const;
74 friend Quaternion slerp(const Quaternion &q1, const Quaternion &q2, scalar_t t);
76 friend std::ostream &operator <<(std::ostream &out, const Quaternion &q);
80 #endif // _N3DMATH2_QUA_HPP_