2 This file is part of XRay, a photorealistic 3D rendering library.
3 Copyright (C) 2005 John Tsiombikas
5 XRay is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 XRay is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with XRay; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 * @author John Tsiombikas
32 #include "vmath_types.h"
42 Quaternion(scalar_t s, const Vector3 &v);
43 Quaternion(scalar_t s, scalar_t x, scalar_t y, scalar_t z);
44 Quaternion(const Vector3 &axis, scalar_t angle);
46 Quaternion operator +(const Quaternion &quat) const;
47 Quaternion operator -(const Quaternion &quat) const;
48 Quaternion operator -() const;
49 Quaternion operator *(const Quaternion &quat) const;
51 void operator +=(const Quaternion &quat);
52 void operator -=(const Quaternion &quat);
53 void operator *=(const Quaternion &quat);
55 void reset_identity();
57 Quaternion conjugate() const;
59 scalar_t length() const;
60 scalar_t length_sq() const;
63 Quaternion normalized() const;
65 Quaternion inverse() const;
67 void set_rotation(const Vector3 &axis, scalar_t angle);
68 void rotate(const Vector3 &axis, scalar_t angle);
69 /* note: this is a totally different operation from the above
70 * this treats the quaternion as signifying direction and rotates
71 * it by a rotation quaternion by rot * q * rot'
73 void rotate(const Quaternion &q);
75 Matrix3x3 get_rotation_matrix() const;
77 friend Quaternion slerp(const Quaternion &q1, const Quaternion &q2, scalar_t t);
79 friend std::ostream &operator <<(std::ostream &out, const Quaternion &q);
83 #endif // QUATERNION_H_