How to smootly interpolate between möbius transformations? - MathOverflow most recent 30 from http://mathoverflow.net 2013-06-20T01:14:51Z http://mathoverflow.net/feeds/question/5305 http://www.creativecommons.org/licenses/by-nc/2.5/rdf http://mathoverflow.net/questions/5305/how-to-smootly-interpolate-between-mobius-transformations How to smootly interpolate between möbius transformations? hyperlogic 2009-11-13T02:57:36Z 2009-11-16T02:37:54Z <p>If you have two Möbius transformations represented as:</p> <p>$f(z) = \frac{az + b}{cz + d}$</p> <p>$g(z) = \frac{pz + q}{rz + s}$</p> <p>where $a, b, c, d, p, q, r, s, z \in \mathbb{C}$</p> <p>Is it possible to derive a third function $h(z, t)$, where $t \in \mathbb{R}$ and $0 \leq t \leq 1$, which "smoothly" interpolates between the transformations represented by $f(z)$ and $g(z)$?</p> <p>Let me try to clarify the meaning of "smoothly". I'm working in a the Poincaré Disc model of Hyperbolic geometry. The functions $f$ &amp; $g$ represent transformations which preserve congruence within the model, i.e. a Poincaré line segment $PQ$ will have the same Poincaré distance as $P'Q'$, where $P' = f(P)$ &amp; $Q' = f(Q)$. I would like the interpolated transform to preserve this property as well.</p> <p><strong>Clarification</strong>:</p> <p>The answers involving diagonalization of the matrix "almost" work. Let me be clearer about how these mobius transformations are used, so that I can give some more context.</p> <p>$f$ represents the position and orientation of a tile on the Poincare disc. I use this to transform a tile centered at the origin. $g$ represents a neighboring tile. I'd like to "animate" the $f$ tile moving it smoothly on top of the $g$ tile. While animating, the center of $f$ should travel along the poincare line connecting the two tiles at rest position.</p> <p>The problem with the diagonalization approach is that the centers of the two tiles will travel about a corner of one of the tiles, sometimes the "long" way around.</p> <p>Of course it could just be a bug in my code...</p> <p>P.S. This is for an iphone game I'm developing called <a href="http://www.circull.com" rel="nofollow">Circull</a></p> <p><a href="http://www.youtube.com/watch?v=DiWijYb-xus" rel="nofollow">http://www.youtube.com/watch?v=DiWijYb-xus</a></p> http://mathoverflow.net/questions/5305/how-to-smootly-interpolate-between-mobius-transformations/5307#5307 Answer by Mariano Suárez-Alvarez for How to smootly interpolate between möbius transformations? Mariano Suárez-Alvarez 2009-11-13T03:03:25Z 2009-11-13T03:03:25Z <p>That you can interpolate follows from the fact that those maps are elements of $\mathrm{PGL}(\mathbb C,2)$ and this group is connected.</p> http://mathoverflow.net/questions/5305/how-to-smootly-interpolate-between-mobius-transformations/5309#5309 Answer by Richard Kent for How to smootly interpolate between möbius transformations? Richard Kent 2009-11-13T03:28:14Z 2009-11-13T03:48:44Z <p>An explicit interpolation is pretty easy to find. (I'll use the upper half plane model.)</p> <p>$f$ is given by $\left( \begin{array}{cc} a &amp; b \\ c &amp; d \end{array} \right)$.</p> <p>$f$ is elliptic, parabolic, or hyperbolic if the trace has absolute value less than 2, 2, or greater than 2.</p> <p>In each case you can easily find, using linear algebra, a $w$ conjugating $f$ to the usual rotation matrix, a matrix like $\left( \begin{array}{cc} t &amp; 0 \\ 0 &amp; t^{-1} \end{array} \right)$, or $\left( \begin{array}{cc} 1 &amp; t \\ 0 &amp; 1 \end{array} \right)$, respectively.</p> <p>This easily gives you a path to the identity. (In the elliptic case, you just take the angle to zero.)</p> http://mathoverflow.net/questions/5305/how-to-smootly-interpolate-between-mobius-transformations/5310#5310 Answer by Darsh Ranjan for How to smootly interpolate between möbius transformations? Darsh Ranjan 2009-11-13T03:30:44Z 2009-11-13T03:39:23Z <p>Yes, it's easy to interpolate. Let $r(z) = f^{-1}g(z) = \frac{r_1z + r_2}{r_3z + r_4}$, where $r_1r_4 - r_2r_3 = 1$. Diagonalize the matrix (if possible): $$R = \begin{bmatrix}r_1 &amp; r_2 \\ r_3 &amp; r_4\end{bmatrix} = V\begin{bmatrix}\lambda &amp; 0 \\ 0 &amp; \lambda^{-1}\end{bmatrix}V^{-1} = V\begin{bmatrix}e^{c} &amp; 0 \\ 0 &amp; e^{-c}\end{bmatrix}V^{-1}.$$ Let $$S(t) = V\begin{bmatrix}e^{ct} &amp; 0 \\ 0 &amp; e^{-ct}\end{bmatrix}V^{-1} = \begin{bmatrix}s_1(t) &amp; s_2(t) \\ s_3(t) &amp; s_4(t)\end{bmatrix}$$ for $0 \leq t \leq 1$ (so $S(0) = I$ and $S(1) = R$), and let $$s(z,t) = \frac{s_1(t)z + s_2(t)}{s_3(t)z + s_4(t)}$$ (so $s(z,0) = z$ and $s(z,1) = r(z) = f^{-1}g(z)$) and finally define $h(z,t) = f(s(z,t))$, so $h(z,0) = f(z)$ and $h(z,1) = f(f^{-1}g(z)) = g(z)$. It seems like a lot of steps, but conceptually, it's very simple. By postcomposing by the inverse of one of your transformations, you effectively reduce the problem to the case where one transformation is the identity. Then it's clear how to interpolate: embed the other transformation in a one-parameter subgroup of the isometry group of the hyperbolic plane, which diagonalizing makes easy. (Exercise: show that $s(s(z,t_2),t_1) = s(z,t_1+t_2)$, so $t\mapsto (z\mapsto s(z,t))$ is indeed an embedding of $\mathbb{R}$ into the group of hyperbolic isometries (i. e., a one-parameter subgroup).) </p> <p>If the matrix $R$ is not diagonalizable, then you can repeat the above construction using the Jordan canonical form instead: </p> <p>$$R = V\begin{bmatrix}1 &amp; 1 \\ 0 &amp; 1\end{bmatrix}V^{-1},$$ and use $$S(t) = V\begin{bmatrix}1 &amp; t \\ 0 &amp; 1\end{bmatrix}V^{-1}.$$</p> http://mathoverflow.net/questions/5305/how-to-smootly-interpolate-between-mobius-transformations/5347#5347 Answer by David Speyer for How to smootly interpolate between möbius transformations? David Speyer 2009-11-13T13:58:29Z 2009-11-13T13:58:29Z <p>The most elegant way to interpolate would probably be $$f \exp(t \log(f^{-1} g)).$$</p> <p>where $\exp$ and $\log$ are given by their power series expressions. That can probably be simplified a lot since we are just dealing with $2 \times 2$ matrices; does anyone want to give it a try?</p> http://mathoverflow.net/questions/5305/how-to-smootly-interpolate-between-mobius-transformations/5360#5360 Answer by Martin M. W. for How to smootly interpolate between möbius transformations? Martin M. W. 2009-11-13T14:52:48Z 2009-11-13T14:52:48Z <p>By now you may have more ideas than you need, but heck, here's another non-matrix viewpoint.</p> <p>In the disk model, you can identify your transformations with lists of three distinct points $(a,b,c)$ on the unit circle, in counterclockwise order. The explicit correspondence is this: For a tranformation $f$, these correspond to $(f(1), f(i), f(-1))$. On the other hand, given three points $(a,b,c)$, you can use the fact that cross ratios are preserved to easily get the formula for $f$ by solving $[z,1,i,-1] = [f(z),a,b,c]$ where $[z_1, z_2, z_3, z_4]$ is the <a href="http://en.wikipedia.org/wiki/Cross-ratio" rel="nofollow">cross-ratio</a>. (There's nothing special about $1,i,-1$ and other choices may make the algebra easier.)</p> <p>Your problem then reduces to interpolating in the space of counterclockwise lists of 3 distinct points on the circle. This is much simpler to think about, and also suggests ways of optimizing to find interpolation arcs that are relatively "short". (I think a "short" path between lists of 3 points will correspond to a visually simple path between transformations, but I haven't verified this.)</p> <p>p.s. Very appealing video! good luck with your game!</p> http://mathoverflow.net/questions/5305/how-to-smootly-interpolate-between-mobius-transformations/5608#5608 Answer by Greg Kuperberg for How to smootly interpolate between möbius transformations? Greg Kuperberg 2009-11-15T06:04:39Z 2009-11-15T06:04:39Z <p>I'd like to address two issues about how to implement these interpolations and what they mean. The group that you ask about is actually equivalent to the group of real M\"obius transformations. If you were in the upper half plane model, the coefficients would be real numbers. You actually don't need to explicitly use the upper half plane model, but you do need the fact that comes from it that all of the motions are elliptic, hyperbolic, or parabolic. The group is called $\mathrm{PSL}(2,\mathbb{R})$.</p> <p>It is widely understood that a good way to make smooth motions in a Lie group is with geodesics. This is an important principle in ordinary 3D computer graphics, where the Lie group is instead $\mathrm{SO}(3)$. A standard method to find the geodesics in this comparison case is with quaternions. As it happens, this introduces a wrinkle with doubled angles that also appears in your case.</p> <p>I assume that you are using $f$ and $g$ as follows: $z$ is a point in the standard bit map of your bird, and then $f(z)$ or $g(z)$ is the mapped position of the bird in your Poincare disk model of the hyperbolic plane. If this is what you are doing, then a correct derivation of the geodesic is $h_t(f(z))$, where $h_t(z)$ is an exponential path from the identity to $g(f^{-1}(z))$. I suppose that the swapped formula that other people have used, $f^{-1} \circ g$, is equivalent.</p> <p>You can find the exponential path by diagonalizing the matrix of $h_1 = g \circ f^{-1}$. However, there is the important wrinkle that the group of matrices is $\mathrm{SL}(2,\mathbb{R})$, which is twice as big as $\mathrm{PSL}(2,\mathbb{R})$. Let $M$ be the matrix of $h_1$. If $M$ is hyperbolic, then it has real eigenvalues. In this case, you should first switch to $-M$ if the eigenvalues are negative. In the basis in which $M$ is diagonal, you should then specifically use $$M_t = \begin{bmatrix} \exp(ct) &amp; 0 \\ 0 &amp; \exp(-ct)\end{bmatrix}.$$ If you use some other choice, you will not follow the geodesic at a constant rate. If $M$ is elliptic, then you should use $$M_t = \begin{bmatrix} \exp(i\theta t) &amp; 0 \\ 0 &amp; \exp(-i\theta t)\end{bmatrix},$$ again in a (complex) basis in which $M$ is diagonal. But here, how do you choose between $M$ and $-M$? The total geometric rotation is $2\theta$, not $\theta$. You should negate $M$ if after you diagonalized, $\theta$ is more than $\pi/2$; if you don't do that you might rotate by more than 180 degrees. In the parabolic case (which you might not see because it requires a numerical coincidence), $$M_t = \begin{bmatrix} 1 &amp; t \\ 0 &amp; 1\end{bmatrix}.$$</p> <p>Finally, in computer graphics you might want a smooth trajectory accelerate from 0 at the beginning and decelerate to 0 at the end. With the confidence that $t$ in the above formulas follows the geodesic at a uniform rate, you can do something like $t = \sin(s)^2$ and use $s$ as the time parameter instead.</p>