Jump to content
  • Advertisement
Sign in to follow this  
MrRowl

Interpolating (slerp) between large rotation angles

This topic is 2910 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

Let's say I have two rotations, A(t) and B(t) that vary over time t. B(t) happens to be an extrapolation of an original rotation so B(t) = B(0) + t * dBdt, where dBdt is the original/constant rate of change of B.

What I want to calculate is a slerp between A and B:

Result(t) = slerp(A(t), B(t), T)

for T increasing from 0 and 1 (i.e. T = someConstant * t).

However, if A and B are represented by quaternions, then even if they start off in the same hemisphere, then after a while the direction of the slerp can (does!) flip, making the result discontinuous. In fact, if dBdt is big enough then B(t) needs to actually represent a rotation that is multiple complete revolutions. Quaternions obviously don't manage this.

Can anyone suggest a solution to this (e.g. involving intermediate representation using rotation vectors)?

One improvement would/might be to add on a fraction of the extrapolation after the slerp:

C(t) = slerp(A(t), B(0), T)
result(t) = C(t) + (1 - T) * t * dBdt

So long as A(t) and B(0) don't diverge much, then this should make result continuous, though it wouldn't be a "proper" large-angle slerp. I just wonder if anyone has a better idea :)

Share this post


Link to post
Share on other sites
Advertisement
Would it not be sufficient not to interpolate the rotation but the angle? I.e. using an axis/angle representation with a constant axis and varying angle
[ a, α0 * ( t - 1 ) + α1 * t ] for 0 ≤ t ≤ 1
followed by a subsequent conversion into a quaternion or matrix. In this case the angle could easily be greater than 180°, even greater than 360°, too.

Share this post


Link to post
Share on other sites
Quote:
Original post by haegarr
Would it not be sufficient not to interpolate the rotation but the angle?


Well, yes - I can represent A(t) and B(t) as angle-axis (well, it might be a little fiddly to calculate B(t) in angle-axis form - need to think about that). However, the real problem is how to then find the rotation from A(t) to B(t) in angle-axis form. Of course, once I have that, interpolating the angle is easy :)

Share this post


Link to post
Share on other sites
I would suggest rearranging the interpolation to be partially iterative rather than time-dependent. Maintain Result(t) such that Result(0) = A(0). Each frame, compute Result(t) = slerp(Result(t-Δt), B(t), Δt * (T-t)/T). This will not ensure the continuity of angular velocity, but it will ensure the continuity of orientations.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
I would suggest rearranging the interpolation to be partially iterative rather than time-dependent. Maintain Result(t) such that Result(0) = A(0). Each frame, compute Result(t) = slerp(Result(t-Δt), B(t), Δt * (T-t)/T). This will not ensure the continuity of angular velocity, but it will ensure the continuity of orientations.


Continuity of angular velocity is essential, but what you wrote (bearing in mind I think you swapped A and B) might work... :)

Thanks for all replies so far and any to come!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!