Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


interpolating from unit quat to arbitrary quat

This topic is 5812 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

if i want to take a percentage of a given amount of rotation, represented by a quaternion, i currently just use my lerp or slerp function with an identity quaternion as the starting rotation. so, it looks something like this: quaternion quatPercentage(quaternion quat, float amount) { quatIdentity.w = 1.0f; quatIdentity.x = quatIdentity.y = quatIdentity.z = 0.0f; return Slerp(quatIdentity, quat, amount); } my question is, is there an easier (i.e. faster) way to interpolate a quaternion if the starting rotation is zero? for example, maybe multiplying the entire quaternion or just the vector part by the percentage and re-normalizing?

Share this post

Link to post
Share on other sites
First looking at the code for SLERP you could use the fact that you are interpolating from the identity quaternion in two ways:

In working out the angle between the quaternions, the initial dot product simplifies greatly. You still need to do the arccos, generally the most expensive step.

In working out the final quaternion both input quaternions get multiplied by a scaling factor before being summed. If one of the quaternions is {1, 0, 0, 0} this multiplication is trivial and can be pretty much eliminated.

The third thing you can do applies to SLERP in general: if you are performing the same calculation reapeatedly between the same two quaternions you need not repeat half of the calculation steps: you can instead store the angle between the initial quaternions and the sine of it and re-use this. I''ve not seen a SLERP implementation that does this but it''s not too hard to do your own version.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!