From 5ff96967a06cdea54600d7ebac1c9cd038540884 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 30 Apr 2012 13:40:51 +0000 Subject: [PATCH] math: add Quat::transform() to directly apply a quaternion to a vector. --- src/lol/math/vector.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lol/math/vector.h b/src/lol/math/vector.h index 8a7c4f6c..a68bb804 100644 --- a/src/lol/math/vector.h +++ b/src/lol/math/vector.h @@ -947,6 +947,13 @@ template struct Quat return Quat(w, -x, -y, -z); } + inline Vec3 transform(Vec3 const &v) + { + Quat p = Quat(0, v.x, v.y, v.z); + Quat q = *this * p / *this; + return Vec3(q.x, q.y, q.z); + } + #if !defined __ANDROID__ template friend std::ostream &operator<<(std::ostream &stream, Quat const &v);