1

I have two transformation matrices and I want to interpolate between them for an animation. As mentioned here it is not possible to simply interpolate the single values. Is there an easy way to accomplish this? (I use Eigen3)

My Idea:

Eigen::Matrix4f m1; //Transformation Matrix 1
Eigen::Matrix4f m2; //Transformation Matrix 2
Eigen::Quaternion<float> quat1(m1.block<3,3>(0,0)); //This extracts rotation matrix
Eigen::Quaternion<float> quat2(m2.block<3,3>(0,0));
quat1.slerp(t,quat2); //This interpolates

//Now i need a 4x4 Matrix again
Eigen::Matrix3f rot=quat1.toRotationMatrix();
Eigen::Matrix4f newmatrix;
newmatrix.block<3,3>(0,0)=rot;

Is there something wrong with my code and is there an easy way to accomplish (rotation) matrix interpolation?

Community
  • 1
  • 1
Captain GouLash
  • 1,257
  • 3
  • 20
  • 33

1 Answers1

0
  1. Modify this lines

    Eigen::Quaternion<float> quat3  = quat1.slerp(t,quat2); //This interpolates
    //Now i need a 4x4 Matrix again
    Eigen::Matrix3f rot = quat3.toRotationMatrix();
    
  2. Also, interpolate linearly translation component (last column of m1 and m2)

  3. Be sure, that m1 and m2 are Euclidean transformations, NOT projective.

cbuchart
  • 10,847
  • 9
  • 53
  • 93
minorlogic
  • 1,872
  • 1
  • 17
  • 24