Calculating relative position of points when zoomed in and enlarged by a rectangle There is a rectangle, defined by the top left point $R1(0, 0)$ and the bottom right point $R2(200, 200)$ (the $y$ $axis$ is inverted).
In that rectangle, there are some points $P1(100, 100)$, $P2(50, 50)$ and $P3(150, 150)$.
Now there is another rectangle, defined by $R3(25, 25)$ and $R4(100, 100)$.
Here is a picture (sorry for my horrible paint skills):

So now, I am trying to calculate the coordinates of the points inside the blue rectangle, when rectangle pink is enlarged to the size of the blue rectangle, zoomed in. The points have to still be in their relative location to rectangle pink.
With relative location I mean that if you move one point to the right by $x$, all other points also have to be moved by $x$, so that they always keep the same distance from each other.
Here's what I have so far:


*

*Subtract $R3$ from point $P$ (which can be any point $Pn$)

*Multiply $Px$ with $$\frac{R2x - R1x}{R4x - R3x}$$

*Multiply $Py$ with $$\frac{R2y - R1y}{R4y - R3y}$$

*Repeat for every point


It doesn't matter that some points might lie outside of the rectangle (like $P3$).
As far as I know, this works, but maybe I missed something.

Now my question is, is this approach correct, i.e. does it always work for any points? Are there any flaws, can it be improved? Thanks for the help! :)

Note that you are dealing with squares, not rectangles, so scale factor for $x$ is the same as the scale factor for $y$. In fact, the scale factors should be equal if both rectangles are similar.
In terms of pure geometry, I consider this to be 2 transformations, a dilation followed by a translation. In terms of a web page, I would scale each point and then scroll the window to the corner of the pink rectangle.
In either case, the scale factor is $\frac{200}{75}=\frac{8}{3}$. Multiply each coordinate by $\frac{8}{3}$ to achieve the dilation/scaling.
Now R3 is at about (66.7, 66.7), so subtract about 66.7 from the new $x$ and $y$ values of each coordinate to achieve the translation/scroll.
Alternatively, you can to the geometric transformations in the other order (translation first, then dilation). If you do, be sure the amount you subtract from each coordinate is only 25 (the pre-dilation value of R3).
