summaryrefslogtreecommitdiff
path: root/ucoo/math/quaternion.tcc
diff options
context:
space:
mode:
Diffstat (limited to 'ucoo/math/quaternion.tcc')
-rw-r--r--ucoo/math/quaternion.tcc21
1 files changed, 21 insertions, 0 deletions
diff --git a/ucoo/math/quaternion.tcc b/ucoo/math/quaternion.tcc
index 19fe7af..e648974 100644
--- a/ucoo/math/quaternion.tcc
+++ b/ucoo/math/quaternion.tcc
@@ -68,6 +68,27 @@ Quaternion<T>::rotate (const vect3d<T> &v) const
return vect3d<T> (nx, ny, nz);
}
+template<typename T>
+T
+Quaternion<T>::yaw () const
+{
+ return std::atan2 (2 * (x * y + w * z), w * w + x * x - y * y - z * z);
+}
+
+template<typename T>
+T
+Quaternion<T>::pitch () const
+{
+ return std::asin (-2 * (x * z - w * y));
+}
+
+template<typename T>
+T
+Quaternion<T>::roll () const
+{
+ return std::atan2 (2 * (y * z + w * x), w * w - x * x - y * y + z * z);
+}
+
} // namespace ucoo
#endif // ucoo_math_quaternion_tcc