Advertisement

interpolating from unit quat to arbitrary quat

Started by November 18, 2002 05:10 PM
0 comments, last by jorgander 22 years, 3 months ago
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?
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.
John BlackburneProgrammer, The Pitbull Syndicate

This topic is closed to new replies.

Advertisement