Fine tuning matrix slerp

22 Views Asked by At

I'm looking for help on getting a proper matrix slerp going. I'm hoping to get it to work with arbitrary matrices, since I'm using this as part of a skeletal system that is not always rotating around origin.

Currently, my matrix slerp works this way:

 1. Convert the rotational parts of each matrix to Quaternions Q1 and Q2
 2. Extract the translation part of each matrix out into Vectors V1 and V2
 3. Slerp the quarternions 
 4. Lerp V1 and V2
 5. Reassemble the rotation part of the matrix from the Quaternion Slerp
 6. Reassemble the translation part of the matrix from the V1/V2 Lerp

This functionally seems to work well, UNLESS one of the matrices is not rotated around origin. Consider this GIF, which is just a simple hinge:

enter image description here

Red is Identity Matrix
Yellow is the final matrix
blue is the slerp.

The green dots represent the "real" center of the mesh (0,0,0 in mesh space). The matrix the yellow image is built from looks like this:

Matrix yellowMatrix;
yellowMatrix.Translate(0,1,-.125f); // Block is .25 high
yellowMatrix.RotateX(80);
yellowMatrix.Translate(0,-1,0);

Ideally, I'd get a smooth rotate around the hinge, but my slerp'd matrix is not taking into account how far origin needs to be offset to follow a "curve" around the hinge that it's rotating on.

So it's easy to see from the GIF that the slerp'd matrix's "center" must follow a curve, and not a straight line lerp between the two. Is it possible to do this with only the information provided in the two matrices, and if so, how??

0

There are 0 best solutions below