<p>As a general rule, you cannot interpolate transformation matrices. In stead, you decompose them into their individual values, then interpolate those and recompose. </p>

<p>The Möbius transformation as suggested in the comments sounds interesting, but tradionally I'd just extract scale and rotation and interpolate those.</p>

<p>Assuming a transformation matrix</p>

<pre><code>    | a  b |
T = | c  d |
</code></pre>

<ul>
<li>the <em>scale</em> is <code>[sqrt(a² + c²), sqrt(b² + d²)]</code></li>
<li>The <em>rotation angle</em> is <code>atan(c/a)</code></li>
</ul>

<p>You'd now interpolate this scale and rotation angle, recomposing the matrix at each frame.</p>

<p><em>[Edit] Corrected the angle (as spotted by Nathan Reed) [/Edit]</em></p>

CC BY-SA 3.0
2016-09-09T17:45:22.420Z
Shouldn't the angle be `atan(c/a)`? (Or better `atan2(c, a)`, if your language supports that.) Also it's worth noting this assumes the matrix doesn't include shear. If it does, you could try extracting that part and interpolating it separately as well.
Nathan Reed
CC BY-SA 3.0
2016-09-10T15:53:10.723Z
In a pure rotation matrix, _c_ = sin(_t_), and both _a_ and _d_ equal cos(_t_). So maybe both your answers work?
Vermillion
CC BY-SA 3.0
2016-09-10T18:16:20.873Z
Thanks @NathanReed, for correcting the angle! And indeed, this does not take shear into account. I'm used to working in 3D were we can usually get away with ignoring shear, but in 2D transforms I guess shear is used much more frequently.
Paul-Jan
CC BY-SA 3.0
2016-09-10T18:16:27.990Z
@Vermillion: indeed, for a pure rotation matrix they are the same, but for a scaled matrix the scale is different per column (so if you want to use element d in stead, you need to calculate scale first and do something like atan((sx / sy) * c / d).
Paul-Jan
CC BY-SA 3.0
2016-09-09T14:20:34.397Z
2016-09-10T18:18:39.683Z
2016-09-10T18:18:39.683Z
Paul-Jan
<p>After watching <a href="https://www.youtube.com/watch?v=kYB8IZa5AuE">this video</a> on matrices, I tried to make a simple animation of 2D linear transformations. Starting with a set of 2D points in a grid, I applied a 2x2 matrix to each point and obtained a set of transformed points.</p>

<p>I'm not sure how to animate the transition between the initial and final states. At first, I made each point move along the straight path between its initial and final position. This caused problems for rotation matrices. For example, a 180$^{\circ}$ rotation should show the points rotate about the origin in circular arcs, but my method made it look like the whole grid flipped around, without rotating. </p>

<p>A better rotation animation can be made by applying a very small rotation, say 1$^{\circ}$, multiple times. The matrix for a 1$^{\circ}$ rotation is close to the identity matrix:
$$\begin{bmatrix} 0.9998 &amp; -0.0175 \\ 0.0175  &amp;  0.9998 \end{bmatrix}$$</p>

<p>Is there some general formula that can generate a differential transformation matrix, given the full transformation matrix? I would like it to work for any 2x2 matrix, without needing to specify the type of transformation.</p>

CC BY-SA 3.0
2016-08-31T05:40:06.783Z
Yes but due to numerical instability it will eventually skew. I should look up my lecture notes, havent revisited this after I stopped teaching.
joojaa
CC BY-SA 3.0
2016-08-31T14:42:41.197Z
Will it skew for any type of transformation, or only ones that are too large?
Vermillion
CC BY-SA 3.0
2016-09-01T21:08:45.287Z
A transformation matrix only captures the end result of a transformation, not "how it got there". The matrix for 180° rotation in one direction, the matrix for 180° rotation in the other and the matrix for flipping the grid, that is scaling by (-1, -1), all look the same.
Quinchilion
CC BY-SA 3.0
2016-09-06T09:22:29.000Z
The first thought that comes to my mind is you could factor the matrix into a Möbius transformation and then lerp the quantities. https://en.wikipedia.org/wiki/M%C3%B6bius_transformation#Decomposition_and_elementary_properties
MB Reynolds
CC BY-SA 3.0
2016-09-06T14:19:59.963Z
I hadn't heard of the Möbius transformation before, thank you!
Vermillion
<transformations><matrix>
Animating a smooth linear transformation
Vermillion
# Animating a smooth linear transformation

(Asked by: username_0 on 2016-08-30)

After watching [this video](https://www.youtube.com/watch?v=kYB8IZa5AuE) on matrices, I tried to make a simple animation of 2D linear transformations. Starting with a set of 2D points in a grid, I applied a 2x2 matrix to each point and obtained a set of transformed points.

I'm not sure how to animate the transition between the initial and final states. At first, I made each point move along the straight path between its initial and final position. This caused problems for rotation matrices. For example, a 180$^{\circ}$ rotation should show the points rotate about the origin in circular arcs, but my method made it look like the whole grid flipped around, without rotating.

A better rotation animation can be made by applying a very small rotation, say 1$^{\circ}$, multiple times. The matrix for a 1$^{\circ}$ rotation is close to the identity matrix:
$$\begin{bmatrix} 0.9998 & -0.0175 \\ 0.0175 & 0.9998 \end{bmatrix}$$

Is there some general formula that can generate a differential transformation matrix, given the full transformation matrix? I would like it to work for any 2x2 matrix, without needing to specify the type of transformation.

**Tags:** transformations, matrix

> **Comments:**
> **username_1**: Yes but due to numerical instability it will eventually skew. I should look up my lecture notes, havent revisited this after I stopped teaching.  
> **username_0**: Will it skew for any type of transformation, or only ones that are too large?  
> **username_2**: A transformation matrix only captures the end result of a transformation, not "how it got there". The matrix for 180° rotation in one direction, the matrix for 180° rotation in the other and the matrix for flipping the grid, that is scaling by (-1, -1), all look the same.  
> **username_3**: The first thought that comes to my mind is you could factor the matrix into a Möbius transformation and then lerp the quantities. https://en.wikipedia.org/wiki/M%C3%B6bius_transformation#Decomposition_and_elementary_properties  
> **username_0**: I hadn't heard of the Möbius transformation before, thank you!  

---

## 1 answers

### Answer by username_4 on 2016-09-09. Score: 6 | Accepted answer

As a general rule, you cannot interpolate transformation matrices. In stead, you decompose them into their individual values, then interpolate those and recompose.

The Möbius transformation as suggested in the comments sounds interesting, but tradionally I'd just extract scale and rotation and interpolate those.

Assuming a transformation matrix

```
    | a  b |
T = | c  d |

```

* the *scale* is `[sqrt(a² + c²), sqrt(b² + d²)]`
* The *rotation angle* is `atan(c/a)`

You'd now interpolate this scale and rotation angle, recomposing the matrix at each frame.

*[Edit] Corrected the angle (as spotted by username_5 username_5) [/Edit]*

> **Comments:**
> **username_5**: Shouldn't the angle be `atan(c/a)`? (Or better `atan2(c, a)`, if your language supports that.) Also it's worth noting this assumes the matrix doesn't include shear. If it does, you could try extracting that part and interpolating it separately as well.  
> **username_0**: In a pure rotation matrix, _c_ = sin(_t_), and both _a_ and _d_ equal cos(_t_). So maybe both your answers work?  
> **username_4**: Thanks @username_5, for correcting the angle! And indeed, this does not take shear into account. I'm used to working in 3D were we can usually get away with ignoring shear, but in 2D transforms I guess shear is used much more frequently.  
> **username_4**: @username_0: indeed, for a pure rotation matrix they are the same, but for a scaled matrix the scale is different per column (so if you want to use element d in stead, you need to calculate scale first and do something like atan((sx / sy) * c / d).  

---

