fixed copying of library links in install target
[gph-math] / src / quat.h
index d77f70f..aabf2c2 100644 (file)
@@ -1,7 +1,17 @@
+/*
+gph-math - math library for graphics programs
+Copyright (C) 2016 John Tsiombikas <nuclear@member.fsf.org>
+
+This program is free software. Feel free to use, modify, and/or redistribute
+it under the terms of the MIT/X11 license. See LICENSE for details.
+If you intend to redistribute parts of the code without the LICENSE file
+replace this paragraph with the full contents of the LICENSE file.
+*/
 #ifndef QUATERNION_H_
 #define QUATERNION_H_
 
 #include "vector.h"
+#include "matrix.h"
 
 namespace gph {
 
@@ -15,10 +25,16 @@ public:
        Quaternion(float x_, float y_, float z_, float w_) : x(x_), y(y_), z(z_), w(w_) {}
        Quaternion(const Vector3 &v, float s) : x(v.x), y(v.y), z(v.z), w(s) {}
 
-       void normalize();
-       void invert();
+       inline void normalize();
+       inline void conjugate();
+       inline void invert();
 
-       Matrix4x4 calc_matrix() const;
+       inline void set_rotation(const Vector3 &axis, float angle);
+       inline void rotate(const Vector3 &axis, float angle);
+       // rotate by a quaternion rq by doing: rq * *this * conjugate(rq)
+       inline void rotate(const Quaternion &rq);
+
+       inline Matrix4x4 calc_matrix() const;
 };
 
 inline Quaternion operator -(const Quaternion &q);
@@ -30,12 +46,11 @@ inline Quaternion &operator +=(Quaternion &a, const Quaternion &b);
 inline Quaternion &operator -=(Quaternion &a, const Quaternion &b);
 inline Quaternion &operator *=(Quaternion &a, const Quaternion &b);
 
-inline Quaternion conjugate(const Quaternion &q);
-
 inline float length(const Quaternion &q);
 inline float length_sq(const Quaternion &q);
 
 inline Quaternion normalize(const Quaternion &q);
+inline Quaternion conjugate(const Quaternion &q);
 inline Quaternion inverse(const Quaternion &q);
 
 Quaternion slerp(const Quaternion &a, const Quaternion &b, float t);