To demonstrate my suggestion in the comments, let's randomly generate the composition of a scaling, a rotation, and a translation, and apply it to a list of known points:
BlockRandom[SeedRandom[1467827]; (* for reproducibility *)
rot = RotationMatrix[RandomReal[2 π]];
sca = DiagonalMatrix[{#, #} & @ RandomReal[3]];
tr = RandomReal[{-2, 2}, 2]];
pts = {{88, 59}, {96, 11}, {66, 2}, {54, 62}};
new = AffineTransform[{rot.sca, tr}][pts];
Use FindGeometricTransform[]
to determine the TransformationFunction[]
:
{err, tf} = FindGeometricTransform[pts, new, TransformationClass -> "Similarity"];
The first thing to do to recover the parameters from the TransformationFunction[]
is to use TransformationMatrix[]
to obtain the associated homogeneous matrix:
tm = TransformationMatrix[tf]
{{0.221083, 0.272837, 0.0193194}, {-0.272837, 0.221083, 0.426155}, {0, 0, 1}}
We can easily get the translation vector from tm
:
v = tm[[1 ;; -2, -1]]
{0.0193194, 0.426155}
Now, for the linear algebra. Apply the QR decomposition on the leading submatrix corresponding to the composed rotation and scaling:
{q, r} = QRDecomposition[tm[[;; -2, ;; -2]]]
{{{-0.629568, 0.776946}, {0.776946, 0.629568}}, {{-0.351166, 0.}, {0., 0.351166}}}
Note that the r
factor is diagonal, which indicates a genuine scaling transformation. Had the off-diagonal entry been nonzero, this is an indication that the two sets of points are not related by a scaling transformation, and you have more work to do.
In any event, the diagonal elements are not all positive, but we can perform a normalization so that we have a genuine scaling matrix:
di = DiagonalMatrix[Sign[Diagonal[r]]];
sc = Diagonal[di.r]
{0.351166, 0.351166}
Finally, let's get the angle of the rotation matrix:
θ = ArcTan @@ First[di.q]
-0.8898
We now have all the needed parameters. Let's do a few checks:
Max[Norm /@ (AffineTransform[{RotationMatrix[θ].ScalingMatrix[sc], v}][new] - pts)]
2.92964*10^-14
Norm[TransformationMatrix[Composition[
AffineTransform[{rot.sca, tr}],
AffineTransform[{RotationMatrix[θ].ScalingMatrix[sc], v}]]] -
IdentityMatrix[3]]
3.01074*10^-14
Take[tr[[2, 1]], 2, 2]
? $\endgroup$QRDecomposition[]
) to separate them. $\endgroup$