Recommended Posts

I need to visually predict an objects path along a set of nodes, each node being associated with a particular position and orientation (pose).
I take it position and rotation must be interpolated seperately, and that a linear interpolation from euler angles will not produce optimal results for the rotation, although linear will probably be sufficient for position.
Is quaternion interpolation the way to go? How about for position? Linear? Any good references?
I found the following pseudo-code on how to do quaternion interpolation:

Which takes 4 rotation matrices as arguments. What do you do if you only have 2? Or for interpolating between the before-last and last nodes? mat[i+2] would go beyond that.
edit: upon further reading it seems that cubic interpolation may be overkill for what I'm trying to accomplish, and that something similar to what i have below may be all i need?

Share this post

Link to post

Share on other sites

Original post by Silex[...]Is quaternion interpolation the way to go? How about for position? Linear? Any good references?

I found the following pseudo-code on how to do quaternion interpolation:

*** Source Snippet Removed ***

Which takes 4 rotation matrices as arguments.

Yes, quat interpolation is designed exactly for that. Of cource, if you're going to represent your transform data as matrices all the time, it will be inefficient. Better to explicitly keep quaternion and vector, and transform to a matrix in the final stage only.

Al for linear/cubic... Performing linear interpolation via splines will do you no good. It completely looses information about derivatives. So the final spline will not have continous derivative. In other words, will look odd and artificial, with sudden changes of motion direction.

So it's cubic, then. The code you presented performs just that. The "inner_quad_point" results are control points, that can be precomputed, so it's not a big deal. As well as angles for slerp (in most cases).

Translation should also be cubic. Same reasons.

Quote:

Original post by SilexWhat do you do if you only have 2? Or for interpolating between the before-last and last nodes? mat[i+2] would go beyond that.

Two options:1 - use last quaternion as post-last too, and first as pre-first (like: q[0],q[0],q[1],q[2] and q[n-3],q[n-2],q[n-1],q[n-1])2 - if the path is looping, use last as pre-first, and first as post-last (like: q[n-1],q[0],q[1],q[2] and q[n-3],q[n-2],q[n-1],q[0]).

Quote:

Original post by Silexedit: upon further reading it seems that cubic interpolation may be overkill for what I'm trying to accomplish, and that something similar to what i have below may be all i need?

*** Source Snippet Removed ***

Heh... the rule of thumb says: there are barely few situation when you can cheat the mother nature. In all the other ones, you will get exactly the same that you were trying to escape from, only harder and more complicated.

In other words: interpolating matrices is just walking aroud the interpolation of quaternions. Compare the cost:- matrix inversion, to-axisangle (as a precalculation) and from-axisangle (as interpolation).- on the other hand: angle between quats (as a precalculation) and slerp (as interpolation).- or for cubic: 2 control points, 2 angles between quats (as a precalculation) and 3 slerps, partially precomputed (as interpolation) - but the efect is much, much better.