Skip to content
Snippets Groups Projects
Commit d5efb143 authored by Andreas Orthey's avatar Andreas Orthey
Browse files

more efficient vector rotation without explicitly assigning quaternions

parent 5e0e43f5
No related branches found
No related tags found
No related merge requests found
...@@ -316,8 +316,10 @@ Quaternion3f& Quaternion3f::inverse() ...@@ -316,8 +316,10 @@ Quaternion3f& Quaternion3f::inverse()
Vec3f Quaternion3f::transform(const Vec3f& v) const Vec3f Quaternion3f::transform(const Vec3f& v) const
{ {
Quaternion3f r = (*this) * Quaternion3f(0, v[0], v[1], v[2]) * (fcl::conj(*this)); Vec3f u(getX(), getY(), getZ());
return Vec3f(r.data[1], r.data[2], r.data[3]); double s = getW();
Vec3f vprime = 2*u.dot(v)*u + (s*s - u.dot(u))*v + 2*s*u.cross(v);
return vprime;
} }
Quaternion3f conj(const Quaternion3f& q) Quaternion3f conj(const Quaternion3f& q)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment