How can we derive the angle by which the origin is rotated and axes are shifted given the list of points before the transformation was done and after the transformation is done.
example:
Before transformation - [(-3173.24, 1503.76), (-3173.24, 1599.98), (-2921.24, 1941.7), (-2777.24, 1941.7), (-2969.24, 1905.7), (-2969.24, 1941.7), (-3017.24, 1941.7), (-3065.24, 1905.7), (-3161.24, 2013.6), (-3179.24, 2049.6), (-2759.24, 1905.7), (-3017.24, 1803.81), (-3113.24, 1803.81), (-3161.24, 1803.81), (-3179.24, 1839.81), (-2759.24, 1803.81), (-2777.24, 1839.81), (-2789.24, 1623.98), (-2789.24, 1527.76), (-2760.86, 1737.92)]
After transformation - [(52.12, 146.39), (52.12, 242.61), (592.12, 584.33), (448.12, 584.33), (256.12, 548.33), (640.12, 584.33), (688.12, 584.33), (160.12, 548.33), (64.12, 656.22), (46.12, 692.22), (466.12, 548.33), (208.12, 446.44), (112.12, 446.44), (64.12, 446.44), (46.12, 482.44), (466.12, 446.44), (448.12, 482.44), (436.12, 266.61), (436.12, 170.39), (464.5, 380.54)]
How can we generate the correlation between these points so that given an older point(x, y) we can find the derived point (x', y')
Origin details are not known. We are using a Cartesian coordinate system having x and y axes.
You are looking for a 2x2 rotation matrix M and a 2x1 translation vector T such as:
for all of your points.
Let's say that M is the following Matrix:
And T the following vector:
Each one of your points before transformation
P = (Px, Py)
and after transformationP' = (P'x, P'y)
gives you 2 equations:With a,b,c,d,Tx,Ty being the unknown elements.
Gathering all the equations given by all your points, you can find those unknown elements using optimization algorithms like Levenberg Marquart or Gradient Descent ...
Note that you have 6 unknowns, so you need at least 3 points which will give you 6 equations to solve this problem. (And if you feel like pen and paper, you can solve this by hand :P)
Once you solved the system of equation, you can get the rotation angle theta as the matrix M is the rotation matrix defined by:
Note 1: be aware that in the general case, "Rotation THEN Translation" is not equivalent to "Translation THEN Rotation", simply because if you rotate before, you won't translate in the same direction ;-)
Note 2: my answer suppose that the transformation is really just rotation and translation but if you are not 100% sure that it is the case, the transformation can be an affine transformation (P' = M.P + T with M not being necessarily a rotation matrix) or even non-linear transformation (and in this case, it can't be represented with a matrix and I would use a 2D model like 2D polygons or stuff like that:
f(x,y) = a.x² + b.y² + c.xy + d.x + e.y + f and try a numerical method to find a,b,c,d,e,f) which are less straight forward.