From e1d459ed75b66eb395d77ef1356dc175ff94ab7b Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Fri, 3 Jan 2014 22:23:34 +0000 Subject: [PATCH] math: allow quat * vec3 and quat * vec4 operations. --- src/lol/math/vector.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/lol/math/vector.h b/src/lol/math/vector.h index 1261f6b2..eb2a35ac 100644 --- a/src/lol/math/vector.h +++ b/src/lol/math/vector.h @@ -1035,13 +1035,30 @@ template struct Quat return Quat(w, -x, -y, -z); } - inline Vec3 transform(Vec3 const &v) + inline Vec3 transform(Vec3 const &v) const { Quat p = Quat(0, v.x, v.y, v.z); Quat q = *this * p / *this; return Vec3(q.x, q.y, q.z); } + inline Vec4 transform(Vec4 const &v) const + { + Quat p = Quat(0, v.x, v.y, v.z); + Quat q = *this * p / *this; + return Vec4(q.x, q.y, q.z, v.w); + } + + inline Vec3 operator *(Vec3 const &v) const + { + return transform(v); + } + + inline Vec4 operator *(Vec4 const &v) const + { + return transform(v); + } + template friend std::ostream &operator<<(std::ostream &stream, Quat const &v);