summaryrefslogtreecommitdiff
path: root/ucoo/math/quaternion.tcc
diff options
context:
space:
mode:
authorNicolas Schodet2015-12-23 10:52:43 +0100
committerNicolas Schodet2019-10-07 00:44:57 +0200
commitbd32e6457b51e4f3e94d6cd5af450695e97a36ef (patch)
tree09834a707674ebc135105900cd031cdd896346f2 /ucoo/math/quaternion.tcc
parent5a0c96b930c0dc9b14caea2557779e9a7bad8dfe (diff)
ucoo/math: add quaternion multiplication
Diffstat (limited to 'ucoo/math/quaternion.tcc')
-rw-r--r--ucoo/math/quaternion.tcc12
1 files changed, 12 insertions, 0 deletions
diff --git a/ucoo/math/quaternion.tcc b/ucoo/math/quaternion.tcc
index e648974..1db845b 100644
--- a/ucoo/math/quaternion.tcc
+++ b/ucoo/math/quaternion.tcc
@@ -89,6 +89,18 @@ Quaternion<T>::roll () const
return std::atan2 (2 * (y * z + w * x), w * w - x * x - y * y + z * z);
}
+template<typename T>
+Quaternion<T>
+Quaternion<T>::operator* (const Quaternion<T> &r) const
+{
+ return Quaternion<T> (
+ w * r.w - x * r.x - y * r.y - z * r.z,
+ w * r.x + x * r.w + y * r.z - z * r.y,
+ w * r.y - x * r.z + y * r.w + z * r.x,
+ w * r.z + x * r.y - y * r.x + z * r.w
+ );
+}
+
} // namespace ucoo
#endif // ucoo_math_quaternion_tcc