I know this is a ridiculously trivial problem but for some reason I have been stuck on it for awhile.
Essentially I have two rectangles as defined by their top left and bottom right coordinates. Lets call these points q1_tl, q1_br, q2_tl, q2_br. The goal is to generate a matrix that when multiple with a point on q1 will be translated into its corresponding point on q2.
So if a point is in the center on q1 then it should go to the center of q2 etc etc etc.
Every attempt I have made thus far has been wrong. The only thing I am pretty sure is that this matrix needs to be 3x3.
Preferably the matrix would have [0 0 1] as the bottom row if it is 3x3 which I think it needs to be. In order to do this I think I should take my original point and make it like (x, y, 1) adding a 1 as its 3rd component.
This is a really difficult thing to google as all the solutions I can find are solutions to much more complex problems.
From your description I take it both rectangles have sides parallel to the coordinate axes. (Otherwise I don't know what to make of "top left" and "bottom right.") The transformation you want can be realized as the composition of three transformations: two translations and a scaling.
Look at the section title "Translation and Scaling" in this paper. (You probably already know this, I think.) First translate the first rectangle so that one vertex, say the lower left, is at the origin. Call this transformation $T_1.$ Then scale the first rectangle so that it becomes the same shape as the second rectangle. You just have to multiply the $x$ and $y$ coordinates by the ratio of the two rectangles' corresponding sides. Call this transformation $T_2.$ Finally, translate the origin to the lower left corner of the second rectangle. Call this transformation $T_3$. The transformation you want is $T_3\circ T_2\circ T_1$ so you just have to multiply the matrices.