I've got a set of points (currently 4, but I can increase the number for better accuracy), and I want to find the optimal transformation so that they can be mapped to another set of points.
For example, I have (2,2), (2, 4), (4, 2), (4, 4) which makes a 2x2 square if these points were connected. I have another set of points, say (2, 2), (2, 5), (3,2), (5,5) which resembles the shape of a rectangle, but clearly stretched, skewed, translated, or even possibly rotated. Using these two sets of points, how can I find the optimal skew factor, stretch factor, translation magnitudes (x and y) and rotational degree to apply to all points in set A so that they overlay as precisely as possible on set B?
Note: I'm actually trying to write a program to overlay one image onto another. I have selected points on both images that I know should be matched to each other. However, I'm having trouble calculating how to map one set onto the other. Please excuse the incorrect use of any math terms :P