Algorithm to interpolate between two general \(4\times 4\) matrix \(M_1, M_2\)
- 1. Extract translation \(p_1, p_2\) from \(M_1, M_2\).
- 2. Compute \(R_1\), \(R_2\) (\(3 \times 3\) rotation matrices), and \(D_1\), \(D_2\) (\(3 \times 3\) scaling/shearing matrices) from \(M_1,
M_2\)
- 3. Interpolate linearly position and scaling/shearing \(p(t)=(1-t)\,p_1+t\, p_2\), \(D(t)=(1-t)\, D_1+t\, D_2\)
- 4. Compute quaternions \(q_1\), \(q_2\) from \(R_1\), \(R_2\)
-
- Note \(M\to q\) with \(q=\left( \frac{M_{zy}-M_{yz}}{2 r}, \frac{M_{xz}-M_{zx}}{2 r}, \frac{M_{yx}-M_{xy}}{2 r}, \frac{r}{2}\right)\),
\(r=\sqrt{1+M_{xx}+M_{yy}+M_{zz}}\)
- 5. Compute \(q(t) = \)SLERP\((q_1,q_2,t)\)
- 6. Convert back to matrix \(q(t)\to R(t)\)
- 7. Compute final matrix \(M(t)=R(t)\,D(t)\) with translation \(p(t)\).