From 3a4b7114676488fc69dd99a69243f6782cb877f9 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 18 Oct 2016 16:45:38 +1100 Subject: [PATCH] quaternion: add assignment-multiply operator --- quaternion.cpp | 12 +++++++++++- quaternion.hpp | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/quaternion.cpp b/quaternion.cpp index 7f956afe..ebeaf5a7 100644 --- a/quaternion.cpp +++ b/quaternion.cpp @@ -127,6 +127,15 @@ util::operator* (const quaternion a, const quaternion b) } +//----------------------------------------------------------------------------- +template +quaternion& +util::operator*= (quaternion &a, const quaternion b) +{ + return a = a * b; +} + + //----------------------------------------------------------------------------- template quaternion @@ -251,9 +260,10 @@ namespace util::debug { /////////////////////////////////////////////////////////////////////////////// #define INSTANTIATE(T) \ -template util::vector3 util::rotate (util::vector3, util::quaternion); \ +template util::vector3 util::rotate (util::vector3, util::quaternion); \ template quaternion util::conjugate (quaternion); \ template quaternion util::operator* (quaternion, quaternion); \ +template quaternion& util::operator*= (quaternion&, quaternion); \ template quaternion util::operator/ (quaternion, quaternion); \ template bool util::almost_equal (util::quaternion, util::quaternion); \ template std::ostream& util::operator<< (std::ostream&, quaternion); \ diff --git a/quaternion.hpp b/quaternion.hpp index 362313a3..d1897ea8 100644 --- a/quaternion.hpp +++ b/quaternion.hpp @@ -89,6 +89,11 @@ namespace util { quaternion operator* (quaternion, quaternion); + //------------------------------------------------------------------------- + template + quaternion& + operator*= (quaternion&, quaternion); + //------------------------------------------------------------------------- template quaternion