views:

79

answers:

4

hello,

i store the position of an object in 3d space in a 4by4 transformation matrix. now in order to move the object from the position stored in matrix A to the position stored in matrix B, i would like to interpolate them.

so do i just do this by interpolating each of the 16 values in the matrix, or do i have to take special care about something?

thanks!

+2  A: 

Just interpolating the matrix values likely won't give you what you want unless you're only doing very simple transformations (for example, translation or scaling).

I think there are methods that decompose a matrix into translation, rotation, scaling, etc. and then you could build new matrices that interpolate based on those parameters.

You could also just do a before and after transformation, and then lerp the verts of the object. This may also not give you the results you're after.

tfinniga
+2  A: 

I assume what you're asking is, you've got an object x, you've applied a linear transformation A to it to get Ax, and now you want to transform it such that it will be in the position it would have been if you applied some other transformation B ie. transform from Ax to Bx.

Assuming A is invertible, just apply BA-1 to get BA-1(Ax) = Bx

[Edit] Since you mentioned moving, you may instead be talking about an affine transformation (a linear transformation followed by a translation). If this is the case, you are looking to move
from Ax + C to Bx + D.

To do this, subtract C (ie. move the object to the origin), apply BA-1, and add D:
(BA-1((Ax + C) - C)) + D = Bx + D

BlueRaja - Danny Pflughoeft
+3  A: 

Check out Ken Shoemake and Tom Duff's Matrix Animation and Polar Decomposition . The basic idea is to break down transformation matrices into meaningful components like stretch, rotation, and translation, and then to interpolate those.

brainjam
+1  A: 

If you interpolate all 16 entries of your matrix, the result will look strange since the interpolated matrices will not be rigid transformations (you will get skewing and volume deformations). The proper thing to do is to separate out the translation and rotation/scaling, giving you a translation vector T and a 3x3 rotation matrix R (this only works assuming your original 4x4 represented a rigid transformation). Then take an eigenvalue decomposition of the 3x3 R=Q'DQ (tick means transpose), giving you an orthogonal Q and diagonal scaling D. Now you linearly interpolate T and D, while you slerp the columns of Q, and then you reassemble the matrix.

Victor Liu