From 73dc6896b5787f4e7f2d332968852e6ce4eee8ed Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Fri, 27 Sep 2019 21:15:42 -0700 Subject: Added Quaternion::RotateVector method --- Common/interface/BasicMath.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Common/interface') diff --git a/Common/interface/BasicMath.h b/Common/interface/BasicMath.h index 1e2c2c55..8623bb47 100644 --- a/Common/interface/BasicMath.h +++ b/Common/interface/BasicMath.h @@ -1710,6 +1710,12 @@ struct Quaternion *this = Mul(*this, rhs); return *this; } + + float3 RotateVector(const float3& v)const + { + const float3 axis(q.x, q.y, q.z); + return v + 2.f * cross(axis, cross(axis, v) + q.w * v); + } }; inline Quaternion operator* (const Quaternion& q1, const Quaternion& q2) -- cgit v1.2.3