#### Archived

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.

## 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 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.

1. 1
Rutin
26
2. 2
3. 3
4. 4
5. 5

• 9
• 13
• 19
• 14
• 9
• ### Forum Statistics

• Total Topics
632940
• Total Posts
3009328
• ### Who's Online (See full list)

There are no registered users currently online

×