2
\$\begingroup\$

I have some code that rotates an object around an axis. It does this by creating a quaternion for a rotation and then multiplying by the old orientation:

nextRot = QuaternionRotationAxis( axis, rotSpeed * elapsed )
newOrient = QuaternionMul( oldOrient, nextRot )

This need to create the rotation quaternion each time seems like it may be redundant. Is it possible to somehow create a quaternion and somehow apply elapsed to it? That is I would prefer code like this:

nextRot = SomeOp( fullRotationQuat, elapsed )

In this way I can store fullRotationQuat in my object and simply apply it partially on each time step.

I know that if I apply nextRot twice, it would be like doulbing the ellapsed time. So I'm guessing I might want some kind of quaternion exponentation. Is this a define op? More importantly, is its performance still acceptable (or faster) than creating from an axis/angle each time?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ What you are trying to do is called quaternion interpolation. Have a look at this \$\endgroup\$
    – bcrist
    May 19, 2014 at 19:58

1 Answer 1

2
\$\begingroup\$

If the axis is fixed, then you can directly construct the orientation quaternion by supplying that axis and the angle. The angle argument is then the only one that changes, just like you want.

If your elapsed factor is constant as well, then you may consider storing the incremental rotation as a quaternion and multiply the old quaternion by this new one each frame (should be faster than evaluating sincos).

In terms of performance, creating a quaternion from angle axis is not a bad idea, but if you can avoid trigonometric functions and square roots, then by all means do it.

As to your "bonus" question on whether it makes sense to think of an exponential operator on the quaternion space, your hunch is right. The only problem I see with this operator is that it's not going to help you in this particular case since it resolves to actually extracting the rotation axis from the quaternion and then building it back again. For more details, consult this short article http://web.mit.edu/2.998/www/QuaternionReport1.pdf . It is here where the properties of the log and exp are explained for quaternions. But their applications usually involve quaternion calculus or storing compressed animation tracks in more complex game engines.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .