# Finding an optimal overlay of two point clouds

Imagine I have two sets of points:

pointSetPerfect = Flatten[Table[{i, j}, {i, 10, 40, 10}, {j, 10, 40, 10}], 1];

pointSetNoise = Table[pointSetPerfect[[i]] + RandomReal[{-2, 2} - 100], {i, 1, Length[pointSetPerfect]}];

r = RotationTransform[47.5 Degree, {0, 2}];
pointSetNoise = r[pointSetNoise];

ListPlot[{pointSetPerfect, pointSetNoise}]


Without knowing what I did above to generate pointSetNoise, I would like to overlay, as best as I can, a set of points on pointSetNoise with the same interpoint spacings as in the point set pointSetPerfect, and return these coordinates. If necessary, I could also click on the image to specify by eye a (very approximate) 1-to-1 mapping between points in either set.

Is there a nice way of doing this in Mathematica v9?

try:

f = FindGeometricTransform[pointSetNoise, pointSetPerfect,
"Transformation" -> "Rigid", Method -> "FindFit"]


I know it's too short for an answer, but that's it.

The result can be tested like this:

ListPlot[{f[[2]][pointSetPerfect], pointSetNoise}, Axes -> False, Frame -> True]


• Yes, that it certainly is. Oct 27, 2013 at 17:27
• I can't believe this was introduced in version 8 and I'm just now finding out about it. Oct 27, 2013 at 17:37
• @RTaylor Mathematica is huge! :) Oct 27, 2013 at 17:44
• I would make sure the method is not set to "perspective" since that changes the inter point distances. "Affine" should do the trick. Oct 23, 2014 at 11:28
• Actually the zero map is also affine but obviously doesn't preserve distances. What you want is a "Rigid" transformation.
– user484
Oct 23, 2014 at 12:48