Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Quaternion Slerp - Shorter way around?

$
0
0
I seem to be having an issue with making a quaternion interpolate through the shortest path. I am making use of Bullet's math/phyiscs package and the quaternion slerp function it provides. My research tells me that when the dot product of two quaternions is negative you should negate one of them. Is my approach correct? It doesn't seem to be producing the correct result. void vSlerp(btQuaternion& start, btQuaternion& end, float t, btQuaternion& result) { start = start.normalize(); end = end.normalize(); float dot = start.dot(end); if (dot > 0.999995) { result=start; } else if (dot >= 0) { result = slerp(start,end,t); // Bullet quaternion slerp } else { result = slerp(start, -end, t); // avoid going the longer way around? } result.normalize(); } Any idea or suggestion is greatly appreciated! Thanks!

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>