2
$\begingroup$

Given two linear transforms in 3D as a matrices $A_0,A_1 \in \mathbb{R}^{3 \times 3}$. I can lerp between them for any "time", $t \in [0,1]$ using an expression such as$^1$ $$ A_t = \exp\left( (1-t) \log(A_0) + t \log(A_1)\right). $$ This gives pleasing interpolations, such as in this example where $A_0 = I$ and $A_1 = \begin{bmatrix}1&-1&0\\0 & 1 & 0 \\ 0 & 0 & 1\end{bmatrix}$:

lerping shear of a cube

Now, consider that I'm not allowed to store or interpolate linear transformations directly. I must decompose each transform into a product of rotations and diagonal matrices (a.k.a., non-uniform scaling transforms). I.e., $A_0 = R_0^1 S_0^1 \dots R_0^n S_0^n$ and $A_1 = R_1^1 S_1^1 \dots R_1^n S_1^n$.

Interpolations will be conducted by slerping rotations and linearly interpolating diagonal matrix entries.

How can I emulate the linear interpolation above under these conditions?

As an example of a poor solution, consider decomposing the input transformations using singular value decomposition:

$$ A = U S V^\top \\ A = \underbrace{\det{(U)}\ U}_{R^1} \ \underbrace{\det{(U)} \ S \ \det{(V)}}_{S^1} \ \underbrace{\det{(V)}\ V^\top}_{R^2} \\ A = R^1 S^1 R^2 $$ By construction, $R^1,R^2 \in SO(3)$ and $S^1$ is diagonal.

Slerping and lerping these transforms for the problem above via:

$$ A_t = \text{slerp}\left(R^1_0,R^1_1,t\right)\ \left((1-t) S^1_0 + t S^1_1\right)\ \text{slerp}\left(R^2_0,R^2_1,t\right) $$

produces an interpolation with the correct end-point values but wild behavior in between:

svd based interpolation of transforms on a cube

Is it fundamentally impossible to get a better interpolation? If not, would using more than two auxiliary rotations per transform help tame this interpolation?

Typically, I have a sequence of transforms $A_0,A_1,A_2, \dots$. So, another phrasing would be, given a decomposition for $A_0$ (i.e., all $R^i_0$ and $S^i_0$ are given) what values for the decomposition of $A_1$ would create the least-motion/least-work interpolation?

$\endgroup$
1
  • 1
    $\begingroup$ I edited your post because it was difficult to parse that the $|$'s were brackets for $|\cdot|$ expressions. I presume $|U|$ refers to the determinant of $U$ in this context (personally, I prefer $\det(U)$); perhaps this deserves an explicit statement. $\endgroup$ Commented Aug 29, 2022 at 12:57

1 Answer 1

1
$\begingroup$

Another method to interpolate from $I$ to a matrix $A$ with $\det(A) > 0$: let $A = USV^T$ be an SVD. We can write $$ A = \underbrace{UV^T}_{R_1}\ \ \underbrace{VSV^T}_B, $$ noting that $R_1$ is guaranteed to be a rotation when $\det(A) > 0$. Notably, $B = VSV^T$ is the spectral decomposition of a positive definite matrix. If $V$ is a rotation, then we're done. Otherwise, as below, we can take $$ B = \underbrace{VD_\epsilon}_{R_2} \ S\ \underbrace{D_{\epsilon} V^T}_{R_3}. $$ I believe that "slerping" preserves the property that $R_2$ and $R_3$ are inverses, which I suspect means that the choice of $D_\epsilon$ used here has no effect on the overall transformation.


An improvement to the approach below: denote $$ D_{\epsilon}^x = \pmatrix{\epsilon &0&0\\0&1&0\\0&0&1},\quad D_{\epsilon}^{y} = \pmatrix{1&0&0\\0&\epsilon&0\\0&0&1}, \quad D_{\epsilon}^{z} = \pmatrix{1&0&0\\0&1&0\\0&0&\epsilon}. $$ For each choice of $D_{\epsilon} \in \{D_{\epsilon}^x,D_\epsilon^y,D_\epsilon^z,\epsilon I\}$, the product $$ A = U S V^T = \underbrace{U D_{|U|}}_{R^1} \underbrace{D_{|U|}SD_{|V|}}_{S^1} \underbrace{D_{|V|}V^T}_{R^2} $$ is a suitable decomposition. I suspect that the "wildness" of the rotation is determined by the angle by which $R^1$ and $R^2$ rotate; a lower angle means a more parsimonious interpolation.

With that in mind, I suspect that a good heuristic for the best candidate $D_{\epsilon} \in \{D_{\epsilon}^x,D_\epsilon^y,D_\epsilon^z,\epsilon I\}$ is to choose the candidate for which the sum of the angle-cosines is maximized, i.e. the candidate for which $$ \operatorname{tr}(UD_{|U|}) + \operatorname{tr}(D_{|V|}V^T) $$ is maximized.


I suspect that using the SVD is a reasonable approach here, but that the particular way that you have chosen to make $U$ and $V$ into rotation matrices (i.e. by multiplying by their determinants) has led to this issue. I suggest the following alternative.

Define $$ D_{\epsilon} = \pmatrix{1&0&0\\0&1&0\\0&0&\epsilon}. $$ Decompose $A$ as the product $$ A = U S V^T = \underbrace{U D_{|U|}}_{R^1} \underbrace{D_{|U|}SD_{|V|}}_{S^1} \underbrace{D_{|V|}V^T}_{R^2}. $$

$\endgroup$
14
  • $\begingroup$ This worked well for my shear tests but produces a wild interpolation when $A_0 = I$ and $A_1 = \begin{bmatrix} 0 & -1 & 0 \\ 1 & 0 & 0 \\ 0 & 0 & 1 \end{bmatrix}$. $\endgroup$ Commented Aug 29, 2022 at 13:28
  • $\begingroup$ That's surprising. What SVD did you get for $A_1$? Since $A_1$ is a rotation and $A_1 = A_1 \cdot I\cdot I $ is an SVD, this should just come down to slerping a rotaiton $\endgroup$ Commented Aug 29, 2022 at 13:31
  • $\begingroup$ I get $A_1 = \begin{bmatrix} 0 & -1 & 0 \\ -1 & 0 & 0 \\ 0 & 0 & 1 \end{bmatrix} \ I \ \begin{bmatrix} -1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}^\top$ $\endgroup$ Commented Aug 29, 2022 at 13:36
  • $\begingroup$ You could get two alternatives by switching $\epsilon$ to a different diagonal entry. For this particular case, replacing $D_{\epsilon}$ with $$ \pmatrix{\epsilon & 0 & 0\\0 & 1 & 0\\0 & 0 & 1} $$ should give us the "better" interpolation. So you could extend this approach to get 3 candidate interpolations, but there's still the question of how to choose the best of the 3 $\endgroup$ Commented Aug 29, 2022 at 13:40
  • $\begingroup$ I think $V$ contains the information of which to use, but I'm not quite there yet. We know that the best fit rotation to $A$ is $U D_{|UV^\top|} V^\top$... I'm trying to force this to be $R^1$ and then handle the shear after. $\endgroup$ Commented Aug 29, 2022 at 13:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .