[Math] How to calculate the new x,y coordinates and width/height of a re-sized group of objects

geometrylinear algebra

I'd like to resize a group of n-objects — either circles or rectangles — all at once and fit them into the newly resized area with newly calculated x,y coordinates and width/height dimensions. The resizing originates in the CENTER of the resized area. It probably helps with some visuals, so please take a quick look at this video:

http://screencast.com/t/AEuJzTS51vja

And here is an image where I'm trying to distill the question as simply as I can. Based on the resizing from the center, I need to know how to calculate the new coordinates and dimensions for "A" "B" and "C" below — I've given the dimensions of the bounding box, both in its original form, and its resized form.

(I know the x,y width/height of "A" "B" and "C" in the orig box — they're just not labeled, but you can assume that they're known values)

How do I calculate the new sizes of the objects in the new bounding box?

Best Answer

If the center of resizing (which it sounds like is the center of your outer rectangle—the one point that is not moved by the resizing) is $(x_c,y_c)$ and you're resizing by a factor of $r_x$ in the $x$-direction ($r_x=\frac{83}{185}$ in your example) and $r_y$ in the $y$-direction ($r_y=\frac{330}{185}$ in your example), then $$(x_\text{new},y_\text{new})=(x_c+r_x(x_\text{old}-x_c),y_c+r_y(y_\text{old}-y_c)).$$

Related Question