# Transformation Matrices

How can I determine a 2x2 trasformation matrix which transforms the triangle with vertices (1,0), (-1,0), and (2,-1) to a triangle with vertices (1,1), (-1,-2), and (3,-2)?

-

## migrated from mathematica.stackexchange.comFeb 10 '14 at 13:31

This question came from our site for users of Mathematica.

This question appears to be off-topic because it is about mathematics, not about TeX & friends. I reccommend migration to Maths.SX. – Jubobs Feb 10 '14 at 9:46
If SE moderators confuse Mathematica and Mathematics no wonder why some users do the same.. – Öskå Feb 10 '14 at 10:21
I said before we should change the name of this forum to Wolfram Language, but no body listens to me. – Nasser Feb 10 '14 at 10:26
Sorry for posting an answer...hmmm – ubpdqn Feb 10 '14 at 11:00

If the question is how to do this with Mathematica then this particular problem can be done using default FindGeometricTransform (documentation here). In this case it can be solved exactly.

For this particular example:

pts1 = {{1, 0}, {-1, 0}, {2, -1}};
pts2 = {{1, 1}, {-1, 2}, {3, -2}};
tr = Chop[FindGeometricTransform[pts2, pts1]]


This yields:

The transform function can be decomposed using CoefficientArrays

{t, m} = Normal /@ CoefficientArrays[tr[[2]][{x, y}]]


where t is translation vector and m is transform matrix.

The result can be tested:

m.# + t & /@ pts1


yields:

{{1., 1.}, {-1., 2.}, {3., -2.}}

as desired

Or plotted:

ListPlot[{pts2, tr[[2]][#] & /@ pts1},
PlotStyle -> {{Red, PointSize[0.03]}, {Green, PointSize[0.02]}}]


More complex pairs of sets of points and contexts would need deeper consideration (rigid, shear, etc). I again refer you to the documentation.

-