interpolation between poses (transformation matrices)

This topic is 5191 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

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:
interpolate_rotation(mat[n],t)

t_int = int(t);

t_fract = t - t_int;

q_0 = mat2quat(mat[t_int-1]);

q_1 = mat2quat(mat[t_int]);

q_2 = mat2quat(mat[t_int+1]);

q_3 = mat2quat(mat[t_int+2]);

q_i = slerp(slerp(q_1, q_2, t_fract),

slerp(i_1, i_2, t_fract),

2*t_fract*(1-t_fract);

return mat2quat(q_i);


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?
m4_transpose(    mt, ms );                /* Inverse             */
m4_mult(         ms, mt, mb );            /* Rotation matrix     */
m4_to_axisangle( ms, axis, angle );       /* Rotation axis/angle */
for ( t = 0; t < 1.0; t += 0.05 )
{
m4_from_axisangle( mi, axis, angle * t ); /* Final interpolation */
... whatever ...
}


[Edited by - Silex on July 29, 2005 12:30:47 PM]

Share on other sites
Quote:
 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.

Share on other sites
Here is an interesting read on quaternion interpolation.

• Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 11
• 23
• 36
• 16
• 75