Sign in to follow this  
yckx

a question about quaternion slerp and commutativity

Recommended Posts

yckx    1298
In my game, the main menu is on one face of a cube, and sub-menus are on other cube faces, at various axis-aligned rotations. Until now, when going from one menu to another, the camera would immediately orient itself to the target menu. Today I implemented a quaternion slerp so that the rotation from the initial orientation to the target orientation could be interpolated over time, producing a smoother visual.

It works, but only in one direction. So, for example, going from the Main Menu to the Options menu rotates smoothly, but going from the Options menu to the Main Menu results in the same sudden shift I had before. I started looking around, and saw references saying that slerp is not commutative, but I haven't found a resource that actually defines commutativity in this context, and was wondering if what I'm seeing is a result of this non-commutativity.

I guess what I'm asking is whether I need to find a different interpolation method, or if I should keep looking for bugs in the code.

Thanks.

Share this post


Link to post
Share on other sites
jyk    2094
If the cube is 'snapping' instantly to the new orientation in one direction but not the other, that sounds more like a problem with the interpolation parameter than with the interpolation method. Are you sure the interpolation parameter is getting reset appropriately?

As for SLERP, I'm not sure if/how commutativity would factor in, but interpolating from q1 to q2 is different than interpolating from q2 to q1, if that's what you mean. But the nature of the interpolation should be the same either way.

One consideration regarding quaternion SLERP is that you'll generally want to negate one of the quaternions if the dot product of the input quaternions is negative to correct for aliasing. But, it doesn't seem like that would account for the behavior you're seeing.

Share this post


Link to post
Share on other sites
yckx    1298
[quote name='jyk' timestamp='1306298771' post='4815444']
As for SLERP, I'm not sure if/how commutativity would factor in, but interpolating from q1 to q2 is different than interpolating from q2 to q1, if that's what you mean. But the nature of the interpolation should be the same either way.

One consideration regarding quaternion SLERP is that you'll generally want to negate one of the quaternions if the dot product of the input quaternions is negative to correct for aliasing. But, it doesn't seem like that would account for the behavior you're seeing.
[/quote]
Ah, so [font="Lucida Console"]slerp( q0, q1, t )[/font] would not yield the same result as [font="Lucida Console"]slerp( q1, q0, 1.0 - t )[/font]? That could pose a problem. Also, I was unaware of needing to check for a negative dot product. Thanks for the info.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this