Composing 2D Similarity Transforms
Similarity transforms come up often in computer vision and gestural interfaces. The results below are a straightforward application of definitions, but didn’t come up in a quick web search, so I though they may be useful to document here on the blog.
In 3×3 matrix form, a similarity transform parameterized by a scale, rotation, and translation is represented as:
[s*cos(th) -s*sin(th) tx ] [s*sin(th) s*cos(th) ty ] [ 0 0 1 ]
Say you have two similarities, T1 and T2, with their parameters as follows:
- scale: s1,s2
- rotation: th1,th2
- translation: (dx1 dy1), (dx2 dy2)
You can represent the composition of T1 and T2 as a third similarity (T3) transform with the same parameterization.
- In matrix form, T3 = T2*T1.
It is perhaps more useful in parameter space, where the result is:
- th3 = th1 + th2
- s3 = s1*s2
- dx3 = s2(cos(th2)*dx1 – sin(th2)*dy1) + dx2
- dy3 = s2(sin(th2)*dx1 + cos(th2)*dy1) + dy2
